PurelyFunctional.tv Newsletter 446: The Art of Domain Modeling
From OO to Clojure Workshop!
Watch my free workshop to help you learn Clojure faster and shift your paradigm to functional.
Design Idea 💡
The Art of Domain Modeling
As you may know, I finished writing Grokking Simplicity about a year ago. Since then, I've had some time to think about a big idea that got cut from the book: domain modeling. And thanks to the focusing deadline of the re:Clojure CFP, I finally have a working definition of domain modeling:
A domain model is:
- an encoding of relevant information
- in a medium (usually a programming language)
- that enables the convenient expression of domain operations
Domain modeling is the design and construction of a domain model.
Why is domain modeling important?
We write programs primarily to communicate ideas to people. Domain modeling is a powerful way to construct concepts. And because we encode it in a programming language, the model must work and be precise. Unlike sketches or English language descriptions of a model, one encoded in a programming language keeps us honest. It is perhaps the most potent form of encoding humans have invented.
Like different people have different understandings of a situation, we can model a domain in many ways. For instance, we can encode numbers in Roman numerals or Arabic numerals. They can represent the same quantities. But one is better for calculating. Imagine a company doing accounting with Arabic numerals in ancient Rome. They would eat their competition for breakfast. A good domain model is a competitive advantage. And as software becomes the center of business, programmers must know how to design good models.
Why a new definition?
Object-Oriented Design and Analysis (OODA) focuses on isA and hasA relationships as if those two relationships can capture everything. The field of Software Design seems oddly nihilistic: Everything is either about code (and its readability) or behavior (what it does). Software design never discusses the meaning of the code---the concepts expressed---nor does it acknowledge that the real world ever existed.
Domain-Driven Design gets quite a lot right. It talks about the difficulties of using words (sometimes words have two meanings) and how different stakeholders need different models even if they're talking about the same thing. But in my opinion, it doesn't discuss enough of the craft of analyzing a domain and building the model.
Over the following issues, I'm going to discuss topics related to domain modeling. I hope you get excited about it. I would love to hear questions, suggestions, and especially disagreements. I appreciate any help you can provide.
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
- Dueling Knights - Submissions
This week's challenge
Longest Alternating Substring
Write a function that takes a string of digits and returns the longest substring that contains only alternating odd/even digits. If two substrings have the same length, return the one that appears first.
(longest-alt-subs "") ;=> "" (longest-alt-subs "1") ;=> "1" (longest-alt-subs "123") ;=> "123" (longest-alt-subs "13") ;=> "1" (longest-alt-subs "122381") ;=> "2381"
Thanks to this site for the problem idea, where it is rated Expert in Python. The problem has been modified.
Please submit your solutions as comments on this gist.