Increasing popularity of Agile software development has made architecture and upfront design much less relevant, in some systems even nonexistent. However, developers still complain about architecture when things get tough and there’s a lot of rework ahead. We expect the architecture to be a solid foundation for future development, not an art of creating confusing diagrams and forcing conventions on developers. I’m at the finish line of reading Lean Architecture for Agile Software Development, and it provides some really interesting insights into the topic.
Putting the Focus on Domain Objects
There are many interesting concepts in the book (it will surely be one of my favorites next to DDD and Clean Code), but one of them is especially appealing to me. It’s the idea of interfaces (or abstract base classes) of domain objects being an output of early architecture work. Why those?
We know from domain-driven design that putting the domain at the heart of software gives foundation to better solutions because business people and their needs are highly connected to the underlying domain. If we manage to express the domain in the software, then the new requirements will fit the existing model, and extending the software should be relatively easy. Much of the work in DDD is connected to discussing with domain experts and picking the right aggregates and entities that can work together to satisfy business needs. In the Lean approach, we want to do something similar, but not quite the same.
In DDD, there’s a whole section about refactoring towards a deeper understanding of the domain. There’s even a story about a team who reaches a breakthrough and has to choose between reworking a huge part of the software to make it better aligned with the domain or continuing to use the old model that doesn’t fit the new requirements well. This is the kind of problem that Lean tries to prevent. We want to eliminate rework late in the project by gathering as much information as possible in the early stage.
Everybody, All Together, From Early On
The secret of the Lean approach is to gather all interested parties from the very beginning and allow them to provide inputs to the architecture. We want to understand the needs of every stakeholder: end-users, business people, domain experts, managers, and even developers. At this point, we leave the nerdy stuff away and we hold on with coding for a while. We try to understand the requirements and the underlying domain and to capture a model that will hopefully fit everyone’s needs. Of course, this might not be possible, and some trade-offs will have to be made. However, we want to know about them and agree on them as early as possible to avoid surprises.
The understanding (model) that we get has to take the form of some artifact that will later help the development team, that will guide them through the development process and prevent re-invent the wheel. It could be a bunch of diagrams, but these have no impact on the codebase unless the developer actually translates them to code. We also don’t want to code the whole domain stuff at the very beginning (that would not be very Agile, would it?). The solution proposed by James Coplien is the use of interfaces or abstract base classes. They impact the code directly and yet they allow you to implement the functionalities one by one.
Testing the Architecture
It would not be very Lean, in the sense of eliminating rework, if we produced a bunch of interfaces that would not actually work in practice. For this reason, we want to test the produced architecture. The process can be as simple as running a design session with developers trying to “simulate” implementing the known use cases using objects that match the proposed interfaces. You should be able to see if all the objects and methods are used, if there is something missing, etc.
It’s Not (Good) Enough
This text is just a rough overview of the idea, not a comprehensive description. I have approached writing this article three times already and I just can’t find the right words to describe it without rewriting a chapter of the book. I hope that it's given you at least some understanding and inspired you to rethink your approach to architecture if you’re still seeing it as ivory towers and diagrams. For a better description, read the book – totally worth it!