Domain-Driven Design Handbook

Svaťa Šimara
Jan 15 · 7 min read

How to apply

1. Hear the story
2. Understand terms
3. Extract scenarios
4. Select use cases
5. Model concepts
6. Write tests + code
7. Connect to the infrastructure

1. Hear the story

The first and most important step of programming. A person who knows the domain, the topic we are going to program, has to explain it to us. Such a person is known as a domain expert. We have to listen carefully.

2. Understand terms

The story is full of new terms for us, terms that repeat over and over again and have important meaning in the domain. Although we may find terms familiar from different domains, we shall explicitly ask for explanation of each important term. Once we understand domain terms, we have a better understanding of the told story. We shall never invent our own terms.

Map terms

Practice shows that terms in a written form aren’t enough for understanding. Any graphical form of terms and their relations is almost necessary. A mind map seems to be a way to describe our understanding back to domain experts and to colleagues.

3. Extract scenarios

The story is the overall explanation of the domain expert daily work, may be abstract, and may be somewhat vague. To understand the domain well, we have to break the story down into smaller pieces that can capture all details. And these smaller pieces are called scenarios.

4. Select use cases

We have to capture key scenarios that will be maintained by our system. Selecting use cases isn’t therefore only domain-related, now we are moving the boundary of the system we create. We define, in other words, capabilities of the system.

5. Model concepts

The model is extracted from domain terms and use cases. Modeling is a hard discipline, we have to understand both the domain deeply and we have to be good technicians. The model that fulfills both aspects is a good model.

6. Write tests + code

Now it’s up to us, we are programmers and programming (+testing) is the job we do the best. We program the domain code, the domain code is completely independent from surrounding layers and therefore it’s very easy to unit test.

7. Connect to the infrastructure

Domain interfaces

Domain layer contains our domain. Up to this point, it was everything we already discussed.

Infrastructure

Infrastructure refers to the fundamental facilities and systems, it consists of sewers, pipes, electrical nets, water supply, garbage collecting and so on.

Summary

5 steps out of 7 aren’t coding. Domain-Driven Design is about
• Understanding the domain
• Discussions with domain experts
• Searching for use-cases and behavior
• Modeling

Carvago Development

Lessons learned and stories from Carvago development team