Scala, Java, Unix, MacOS tutorials (page 124)

One of My “Top-5” Meditation Books
Practicing
the
Jhanas

I’m a big fan of the book, Functional and Reactive Domain Modeling, and these are some of my notes (“CliffsNotes”) from the book, most of them coming from the first chapter.

Chapter 1. Functional domain modeling

  • domain model
    • the representation of how the business works
    • blueprint of the relationships between the entities
    • objects that belong to the domain
    • behaviors those objects have
    • the language/vocabulary of the business
    • the context within which the model operates
  • essential complexities - complexities inherent to the business
  • incidental complexities - complexities introduced by the solution itself

Domain-driven design

  • bounded context - smaller model within the whole; a complete area of functionality within the larger system
  • the complete domain model is made up from a collection of bounded contexts
  • bounded contexts communicate via services/interfaces/APIs (me: think of them as web services)
  • ubiquitous language = domain vocabulary

Entities and value objects:

  • entities have an id (like a database id), and they are mutable; usually has a definite lifecycle
  • value objects (like an address) don’t have an id; they are identified by the values that are contained, and are therefore immutable
  • entity has an id that can’t change, and value object has a value that can’t change

Services:

  • services = behaviors = functions
  • usually models a use case of the business

Object lifecycles:

  • creation
  • participation in behaviors
  • persistence to a data store
  • factories (p.9)
    • centralize code to create entities
  • aggregates - a transaction boundary in the model
  • aggregate root - guardian of the graph and single point of interaction of the aggregate with its clients
  • Effective Aggregate Design by Vaughn Vernon

Scala:

  • Use case classes to model aggregates (ADTs)
  • Traits let you define modules which can be composed using mixin composition

Repositories:

  • the interface (trait) has no knowledge of the underlying data store

Thinking functionally

  • functions are the main abstraction to model domain behaviors (standalone functions in modules (traits), like Haskell)
  • mutable state is an anti-pattern when it comes to reasoning about your code
  • pure functions ...
  • general principles:
    • model immutable state as ADTs with case classes
    • model behaviors as functions in modules
    • behaviors in modules operate on their corresponding ADTs
  • more:
    • ADTs have no behaviors
    • services are defined in modules, which are implemented as Scala traits
    • when you need a concrete instance of a trait, create it with the object keyword

1.3.2 Pure functions compose (p.22)

  • good examples
  • composition = Unix pipeline (me)
  • HOFs like map are known as combinators
  • andThen and compose examples
  • takeaway: “appreciate how function composition through combinators can lead to enrichment of domain behaviors”

1.4 Managing side effects

  • stuff like I/O
  • decouple side effects as far as possible from pure domain logic

1.5 Virtues of pure model elements

  • equational reasoning
  • substitution model of evaluation
  • substitution model only works if functions are pure
  • referentially transparent expressions
  • three pillars of functional programming
    • referentially transparency
    • substitution model
    • equational reasoning

Other good quotes/notes

“Abstractions compose when types align; otherwise you’re left with islands of artifacts you can’t reuse and compose.”

About monads and effects in functional programming:

  • Future models latency as an effect
  • Try abstracts the effect of failures (manages exceptions as effects)
  • Option models the effect of optionality

Functional and Reactive Domain Modeling

If you haven’t read it yet, I highly recommend the book  Functional and Reactive Domain Modeling, with one caveat: it tends to assume that you already know a lot about functional programming. For example, if you already know what functors and monads are, it can help you understand how to use them in Scala. If you don’t already know what those things are, I’ll point you to my own book, Functional Programming, Simplified, about 40% of which you can read for free.

When asked, “If you could give one tip for reaching heights in tech today, what would it be?”, this was the initial response from Jonas Bonér, creator of Akka:

  • Work hard at minimizing your ego & attachment to identity
  • Learn deliberately, seek out weaknesses & work hard at them
  • Eliminate bad habits, replace them with good, one at a time
  • Read a lot, foundational stuff, not just latest hyped thing

Probably the most important lesson I learned from aimlessly wandering around Alaska and the Lower 48 for five years is that if you treat complete strangers as long-lost brothers and sisters that you’re meeting for the first time, the world magically becomes a better place.

When I met my mom, Sister #2 and her husband in New Mexico in 2017, I brought my mom a bunch of junk food. The Twinkies didn’t make much of an impact on her, but when Sister #2 gave her a chocolate cupcake, my mom’s approximate words were, “OMG, this is the best thing I have ever eaten in my entire life.”

When I was in New Mexico a few years ago I met a woman who suggested that I needed to quit fighting a particular feeling I have been experiencing. She said that it was my heart chakra attempting to open, but each time it started to open, my Little Ego wouldn’t surrender, it held on to things as they are for dear life. She said that if I would just let go, I’d be on the path to loving all humans unconditionally.

On the drive home I was rudely cut off by a woman in a Mercedes, who was quite literally driving in my lane. As I moved out of her way and we passed each other, she glared at me like I was doing something ridiculously wrong by driving in my own lane. “Humans are a hard species to love,” I thought.

After that experience I decided to start counting all of the people I love or have loved, and if you include Neil Diamond – I threw him in there because my mom liked him so much – I got up to 49.

Somehow I have to find a way to get from 49 to several billion, including the glaring woman in the Mercedes. I think I’m going to have to work on my technique, or perhaps on my definition of “love.”

I just ran across this chart from Morningstar that includes eight stocks with share repurchase programs. In general, I’m a fan of buying the stocks of companies that have share repurchase programs, but, you also have to look into the details of how and why they’re doing this, and you also have to understand the business behind each company. For instance, I’ve never heard of LB, so I looked them up, and I have no interest in investing in an apparel company, so immediately I scratch them off.

Other companies like CAH, MCK, and CVS (who suspended their share repurchase program to buy Aetna) are currently beaten down because of the threat that Amazon will enter their business space, so my first thought is that they’re buying back their stock because it’s at a significant discount. But again, you also have to look into their financials to see how they’re buying back their stock — is it from cash flow? Or are they borrowing money to buy their stock, and if so, how long will it take to pay off those loans?

Eight stocks with share repurchase programs

While it’s old news (March, 2018), I’ve often wondered why Siri seems to be getting worse, and how/why Amazon and Google beat Apple to the market for Alexa-like assistants. MacRumors has this article where they report several of the problems related to Siri’s development. (Their article is based on an article written by The Information, which requires a subscription.)

I just happened to look out the window last night (Sunday, July 15, 2018) at the right time and saw the Moon and Venus hanging out together.

The Moon and Venus

July 15, 2018: A little less than three weeks ago I had a type of surgery known as a colectomy, a procedure where a portion of the colon is surgically removed. The background of the story goes like this: Because of pain I was having whenever I tried to eat, I haven’t been able to eat solid foods since October, 2017. After eight months of hoping the problem would heal itself, I was finally forced to give up that hope when it became apparent that surgery was the only hope for a relatively normal life.

From this AirBnB article about using React Native: “JavaScript is an untyped language. The lack of type safety was both difficult to scale and became a point of contention for mobile engineers used to typed languages who may have otherwise been interested in learning React Native ... A side-effect of JavaScript being untyped is that refactoring was extremely difficult and error-prone.”

The 90/90 Rule: “The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.”

~ Tom Cargill

From this vox.com article: “When the 12 Thai boys who were trapped in a cave and were rescued one by one were first discovered by British divers last Monday, they were reportedly meditating ... Turns out that their coach, Ekapol Chanthawong, trained in meditation as a Buddhist monk for a decade before becoming a soccer coach.”

From this CNN article, “Older people with higher-than-average blood pressure have more markers of brain disease than their average-pressure peers, according to a study published Wednesday in the journal Neurology ... researchers saw increased signs of areas of dead tissue caused by a block in the blood supply to the brain, when looking at postmortem tissue under a microscope. Autopsied brains also revealed that higher-than-average blood pressure is associated with one marker of Alzheimer's disease.”

Here’s An Illustrated Proof of the CAP Theorem, if you’re into things like consistency, availability, partition tolerance, and distributed systems.

An Illustrated Proof of the CAP Theorem

I haven’t tried it yet, but if you’re interested in a Scala HTTP client, the people at softwaremill.com have sttp, and its docs are here.

Today a person did something that upset me. For a few moments it really bothered me and I thought, “Wow, this person is being a real jerk.” Then I remembered the phrase, “Every obnoxious act is a cry for help,” and I realized that this was this other person’s way of saying that they were hurting, and it helped me calm down in regards to them.

If you’re interested in the future of Scala, i.e., Scala 3, also known as Dotty, Martin Odersky recently shared a working draft document titled, Functional Typelevel Programming in Scala. See the “Files Changed” link on that page for the complete working document.

Functional Typelevel Programming in Scala (Martin Odersky)

“You are more beautiful than music.”

“Your face is like a poem.”

“And in your eyes ... heaven.”

A bumper sticker seen in Alaska on July 5, 2010: “I don’t mind straight people as long as they act gay in public.”

One of My “Top-5” Meditation Books
Practicing
the
Jhanas