January 30th, 2022 update
Hey, aspiring phronimos developer.
Here’s what’s up.
Into 2022: Current book status
What’s the current status of the book? I’m back on the train. Early January had me pretty busy with some exciting Apollo Federation work but now I’m back to writing daily on this project.
Current target
My current goal is to finish the OO, design patterns, and design principle sections by the end of March 2022. At the time of writing this, we’re about 30% done the quarter 🙂 .
Tell me more about design patterns
In this, we’ll cover the main categories of design patterns (behavioural, structural, creational), discuss them all at a high-level, but we spend some time acclimating ourselves to a select few that I believe to be the most common ones you’ll encounter in real-life situations.
Tell me more about design principles
This is a section of the book that I’ve been waiting to get to for a really long time.
Hard and fast rules are good for specific tools, technologies, and situations, but principles cast a much wider net. While principles may not always tell us exactly what to do, they help us build a better understanding of the laws of software design and what it takes to implement Simple Design.
Guided by principles, we dodge blunders, and find ourselves taking more virtuous paths without any concrete instructions. We know what decisions lead us towards bad roads and the ones that lead us to bad roads.
Design principles are a sort of perennial voice of reason; they go beyond any tool, technology, or design. It should be no surprise that the tools, technologies, and designs that stand the test of time were sculpted by phronimos developers who rely on design principles. The laws of good design — simplicity, expressiveness, high cohesion and loose coupling — these things can’t be changed. It is what it is. The human brain has limitations and our designs needs to take that into respect. So when building, it’s better to go with the grain of good design instead of against it.
In this section, we’ll cover a number of my favourite design principles that help you do the right thing in a wide number of of scenarios.
How do these sections build on each other?
The object-oriented section is essential for just having a better conceptual model of OO and knowing how create basic designs with minimal shooting-oneself-in-the-foot.
The design patterns section helps you notice opportunities to implement well-known solutions to well-known problems, but design patterns come at a cost. The cost of design patterns is added complexity. So you have to know when that complexity is necessary.
That’s where design principles comes in.
As I mentioned in the last update, our North Star in the never-ending war against complexity is always going to be Simple Design. While the ideas of loose coupling and high cohesion are closer to really encapsulating the idea of mitigating complexity, Simple Design is a principle much easier communicated and expressed through example. It’s also the principle that all other design principles stem from. I draw it out like this:
💡 OO techniques (rely on) → design principles (to express) → simple design (which results in) → loose coupling/high cohesion (to combat) → Complexity
What do I mean by that when I say that “all other design principles stem from Simple Design?”. Well, for example, let’s take “The Law of Demeter”. This principle says that we should only talk to our immediate neighbours.
That means that the following is ideal:
habitsPage.markAllCompleted();
And the following is not:
habitsPage.getAllHabits()
.filter((h) => h.active)
.forEach((h) =>
h.getHabitState()
.setValue(Boolean.TRUE.booleanValue())
})
If we refer back to Simple Design again, we have the following ideas (take special note of the third one):
- We have no duplication
- We have tests that confirm the code works
- The code is as expressive as possible (high cohesion)
- There are as few elements as possible (low coupling)
I think you’ll agree that the first example we looked at adheres more towards expressiveness, simplicity, and high cohesion than the second, right?
When we learn new design principles, our higher-level focus is simple design. And higher than that is loose coupling and high cohesion.
Onwards
Once I finish this first version of the book, I’ll rewrite it for clarity in second and third drafts before finalizing it.
I’m excited to hear all the feedback so far. I can express how happy it makes me to know that the book has been useful so far to so many people, even in the state that it’s currently in. It’s only going to get better.
Questions/suggestions?
If you have any questions or suggestions about the work I’m doing on this, please feel free to shoot me an email at khalil@khalilstemmler.com.