PurelyFunctional.tv Newsletter 458: Three doorways of domain modeling
Issue 458 - January 10, 2022 · Archives · Subscribe
Design Idea 💡
Three doorways of domain modeling
This essay continues the series about Domain Modeling.
I have come up with a three-level model for the skills in domain modeling, which will linearize the material from most fundamental to least fundamental. The three levels, more fundamental first, are: data modeling, operations first, and algebraic composition.
When I wrote Grokking Simplicity (GS), I created a three-level model of functional programming (FP). When teaching complex material, you need to linearize it. And, of course, you need to start with the most fundamental skills first. The three levels in GS are recognizing actions, calculations, and data; higher-order abstractions; and domain modeling. The third level got cut because it didn't quite fit. However, the model provided a map for the material. The most valuable skills were first. The least valuable skills were last.
Unfortunately, as we grow as experts, we focus on higher-level skills. We mistake the power for value. Take, for example, the fervent support for monads in the community. Yes, monads are powerful. But they apply in fewer situations than recognizing pure functions from impure ones. Monads aren't everywhere. But all functions are either pure or impure, and it's vital to FP to distinguish them. It's ironic that we spend chapters talking about how cool monads are and write a sentence about pure functions.
This reversed priority is one facet of the curse of expertise. Experts cannot explain how they do what they do. And I was guilty as well in my recent re:Clojure talk.. I reversed the priority and put high-level process above fundamental skill. It wasn't until the Q&A that I realized my mistake.
So here are the three levels I've identified. I don't know why I've found three, except that maybe it's mnemonic. Too many levels, and you can't keep them in your head. Too few, and it doesn't feel like a system. Each level comes with a gateway skill or realization. Once you gain that skill, it opens up a whole world of skills to explore at the same level.
1. Data modeling
To enter this level, you must realize that some data models fit the world better than others. Misfits lead to more complex code. You want the structure of your model to mirror the structure of the domain. The skills on this level are all about analyzing the domain and evaluating language features for their modeling potential.
2. Operations first
As your skill in analyzing the structure of the domain and encoding it in a data model improves, you will inevitably find that there are still many choices that can lead to poor models. Some models fit well, but they are awkward to use. To enter this next level, you must realize that you can design the operations over the data independently of the representation of the data. Your operations' design will constrain data structure choices to the least awkward. Skills at this level are about designing operations ahead of the data model and analyzing how those operations constrain the data modeling choices.
3. Algebraic composition
After designing the operations first in several domains, it becomes clear that some sets of operations are more expressive than others. What gives them that property? To enter this next level, you must realize that designing the operations to compose is vital. Skills at this level are about designing the algebraic properties of your operations to create expressive domain languages. What properties of operations lead to the flexibility you desire?
So that's the three-level scheme. Each level has a big idea and many related skills the idea unleashes.
The first level is most fundamental. And the last level is powerful but not widely applied. Empirically, it is not that useful. You can learn data modeling without algebraic composition. But you can't design algebras without skill in data modeling.
Readers can stop after reading one level because they've learned something of immediate value. They can chew on the ideas for years before picking up the second level.
New podcast episode🎙
It finally happened! I recorded this beast: Computer Science as Empirical Inquiry: Symbols and Search about how computer science is a science. It's the 1975 ACM Turing Award Lecture by Allen Newell and Herb Simon. Check it out.
Awesome book 📖
Surely You're Joking, Mr. Feynman! by Richard Feynman is a fantastic and inspiring romp through life and science.
My biggest criticism is a lack of outside perspective on his own behavior. For instance, a biography I am reading of him talks about his loneliness after losing his wife, which resulted in him becoming a womanizer with a long string of empty relationships. In Surely You're Joking, Feynman seems to relate the fun and whimsical side of bachelorhood without mentioning the lack of fulfillment in those relationships.
However, it is a great glimpse into his mind.
Awesome podcast episodes🎙
I loved hearing Julie Sussman's story on the JUXT Podcast. Her name has always mysteriously been on the cover of SICP but I never knew why.
Also, the most recent episode has a great discussion of records.
Book update 📘
Grokking Simplicity is still selling strong. I love getting messages on Twitter or over email about how it is affecting people's coding.
You can order the book on Amazon. Please leave a rating and/or review. Reviews are a primary signal that Am azon uses to promote the book. And they help others learn whether the book is for them.
You can order the print and/or eBook versions on Manning.com (use TSSIMPLICITY for 50% off).
Pandemic update 😷
I know a lot of people are going through tougher times than I am. If you, for any reason, can't afford my courses, and you think the courses will help you, please hit reply and I will set you up. It's a small gesture I can make, but it might help.
I don't want to shame you or anybody that we should be using this time to work on our skills. The number one priority is your health and safety. I know I haven't been able to work very much, let alone learn some new skill. But if learning Clojure is important to you, and you can't afford it, just hit reply and I'll set you up. Keeping busy can keep us sane.
Stay healthy. Wash your hands. Wear a mask. Get vaccinated if you can. Take care of loved ones.
Clojure Challenge 🤔
Last issue's challenge
Issue 457 -- Chess moves -- Submissions
This week's challenge
String difference
Imagine two strings, A and B. B is generated by shuffling the letters in A and adding a new random letter to it at a random position. Write a function that takes A and B and returns the new letter.
Examples
(diff "" "j") ;=> \j
(diff "a" "ab") ;=> \b
(diff "abc" "xcab") ;=> \x
(diff "xxyyzz" "xzyfyxz") ;=> \f
(diff "cccvv" "cvvcvc") ;=> \v
Thanks to this site for the problem idea, where it is rated Very Hard in Java. The problem has been modified.
Please submit your solutions as comments on this gist.
Rock on!
Eric Normand