Domain-Driven Design and Clean Architecture

Clean Architecture

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:

I mention this book here because it also has a section on Layered Architecture in which it says:

Isolate the expression of the domain model and the business logic, and eliminate any
dependency on infrastructure, user interface, or even application logic that is not business
logic. Partition a complex program into layers. Develop a design within each layer that is
cohesive and that depends only on the layers below. Follow standard architectural patterns
to provide loose coupling to the layers above.

DDD Reference by Eric Evans

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s