This article is mostly excerpts from my book Code That Fits in Your Head. The overall message is too important to exclusively hide away in a book,

Referential transparency fits in your head by Mark Seemann

submited by
Style Pass
2021-07-28 14:00:07

This article is mostly excerpts from my book Code That Fits in Your Head. The overall message is too important to exclusively hide away in a book, though, which is the reason I also publish it here.

The illustrations are preliminary. While writing the manuscript, I experimented with hand-drawn figures, but Addison-Wesley prefers 'professional' illustrations. In the published book, the illustrations shown here will be replaced by cleaner, more readable, but also more boring figures.

Ultimately, software interacts with the real world. It paints pixels on the screen, saves data in databases, sends emails, posts on social media, controls industrial robots, etcetera. All of these are what we in the context of Command Query Separation call side effects.

Since side effects are software's raison d'รชtre, it seems only natural to model composition around them. This is how most people tend to approach object-oriented design. You model actions.

Leave a Comment