How strongly do I recommend Clean Architecture?
9 / 10
Clean Architecture is to star engineers what Clean Code is to new engineers.
While you may already implement the principles and ideas of Clean Architecture, this book will provide you the language and insights to solidify your intuition into well-articulated knowledge.
Like Clean Code, this book is great for engineering book clubs and provides an opportunity for senior engineers to mentor junior engineers.
Top Ideas in This Book
Good architecture supports high leverage. More users and more functionality supported per engineer.
When you open the codebase for a fitness app, it should look like a fitness app.
We usually fail this test with:
One way to achieve an architecture that matches system intent is through components.
Components are just groupings of code that change for the same reasons.
For instance, your shopping cart app might have a PromoCode component. Anytime the promo code functionality needs changing, you are probably working within the PromoCode directory.
In addition to improving comprehension and cohesion, components help decouple logic from the framework – so you’re not as tied to Rails, Laravel, or whatever framework you’ve chosen.
SOLID principles tell us how to group code and data to support software that tolerates change, is easy to understand, and has components that can be used across software systems.
The SOLID principles are:
Clean Architecture dedicates a chapter to each principle explaining both the benefits and implementation details of each principle.
When creating a new project or adding a new feature, resist the temptation to decide technology upfront. This is often when you understand the problem least and you’re most prone to premature optimization.
For instance, defer the decision on which RDBMS to choose. You might not even need a database – simple file storage might solve the problem equally well while limiting your dependencies.
Soft architectures are open to change, they are not fixed. Soft architectures can be changed in response to changing environments and the realities of customer needs. The architecture you had at the start of a project can and should change as your program evolves.
Independent deployability helps teams deliver faster. Boundaries are clearer between teams. Tests and builds run faster. Problems become more isolated.
Sometimes we swing too far with modularity, splitting code along too granular of lines. We know we’ve over-modularized our code when we must change several components in order to deliver a change. For instance, within an API if we want to build a new API endpoint, it should generally not involve changing multiple components but rather one. The author calls this the Common Closure Principle.
True duplication happens when changing one instance results in changes to other instances. True duplication is bad.
Accidental or false duplication happens when two seemingly duplicated code blocks evolve differently, changing at different times and for different reasons. Architects should not fear this type of duplication and should be careful to not prematurely optimize against it.
When writing an application based on a framework, look for ways to depend on the framework less. General purpose frameworks address lots of use cases that won’t be applicable to the problem you are trying to solve. Perhaps you can find a lighter way to use the framework or you can eliminate it entirely.