A colleague recently mentioned the concept of Clean Architecture (as named by Uncle Bob Martin). The essential idea is to have
- a layered software architecture,
- with the domain objects and business logic at its core
- and all dependencies only pointing inwards
Uncle Bob uses 4 concentric circles to denote the layers of a generic architecture and calls them (from inside to outside): Entities, Use Cases, Interface Adapters and “Frameworks and Drivers”. The outermost layer contains all technical details like the type of database that is used and which web framework (or UI or whatever) is applied.
Of course, Uncle Bob would not be Uncle Bob if he would not suggest to use the dependency inversion principle to have the control flow point in the opposite direction as the dependencies. In my current job, where we work mostly in Rust, we would most of the time rely on traits and in particular the SerDe crate to take the role of the depedency inverter.
Layered Architecture in DDD
Not so long ago, I tried to read the book Domain-Driven Design by Eric Evans. It was also recommended to me by a colleague. But trying to read it I had a really hard time working myself throug the book. The writing style somehow didn’t connect with me that well.
But then, more recently, I did discover the DDD reference which is a little summary of the patterns and definitions of DDD that is also authored by Eric Evans and that can be downloaded for free on this website: https://www.domainlanguage.com/ddd/reference/
I mention this book here because it also has a section on Layered Architecture in which it says: