Bookmarks

DDD — domain-driven design

An approach to software design in which the structure of the code reflects the domain model and is built on its language.

Also: domain driven design, DDD

checked 8 Nov

All terms

DDD starts with understanding the business domain — commerce, insurance, logistics — and building its model together with domain experts; only then is the code designed around that model. Eric Evans coined the term in his 2003 book of the same name.

Strategic design

A large system is split into bounded contexts: each has its own model, its own vocabulary and its own boundaries. The model lives not in paper diagrams but in the code itself and evolves together with the system. For example, in an online shop “product” means different things for the catalogue, the warehouse and delivery — different concepts with different fields. Contexts are connected by explicit translation rules between the models.

Tactical design

ElementMeaning
Entityan object with identity: a customer, an order — two orders with the same total are still different
Value objecta characteristic without identity: the money value “100 sum”, an address
Aggregatea group of objects with a single root; only the root is exposed to the outside, and changes go through it
Repositorycode that stores and retrieves aggregates, hiding the storage
Domain eventa fact that has happened: “order paid”; other parts of the system react to it
Ubiquitous languagethe experts’ terms match the names of classes and methods — the code reads like the requirements

When to use it

  • Worth it for complex domains with rich rules, where the model pays off.
  • Overkill for simple CRUD systems: reference lists and forms need no aggregates or bounded contexts.
  • Often combined with clean or hexagonal architecture and CQRS to separate writes from reads.

Sources

the term is written from these pages

Verified 8 Nov

Not to be confused with

what it is mixed up with and how it differs

  • TDDtest-driven development

    TDD is about how you work with tests: first the test, then the code. DDD is about how to build the domain model.

In depth in the references

where the topic is covered in detail