Domain-driven design (DDD) is an approach to software architecture and programming that places a model of the business domain at the center of the system, shaped jointly by developers and domain experts. Introduced by Eric Evans in his 2003 book of the same name, it targets software whose main difficulty lies in complex business rules rather than in technology.
DDD combines strategic design, which divides a large problem into coherent models with clear boundaries, and tactical design, which supplies building blocks such as entities, value objects and aggregates for expressing each model in code. Its aim is code that speaks the language of the business and changes as cleanly as the business itself changes.
Core ideas of domain-driven design
Domain-driven design rests on the idea that the domain model is the heart of the software, and that the model must be discovered through continuous collaboration rather than specified once. Developers and experts refine it together, and the code is treated as the most precise expression of that shared understanding.
The ubiquitous language is the practical tool for that collaboration. Every term used in conversations, documents, tests and class names means the same thing to everyone within one boundary. When an expert says that an order is confirmed rather than placed, the code uses that exact word, and a change in the language signals a change in the model.
A second central idea is that one universal model does not work for a large organization. The word customer means something different to billing, shipping and marketing, so DDD accepts several models and makes their boundaries explicit instead of forcing a single compromise.
Strategic design: bounded contexts and context maps
Strategic design in DDD organizes a system around bounded contexts, each of which is an explicit boundary inside which one model and one ubiquitous language apply consistently. A bounded context often aligns with a team and frequently with a deployable unit, although it is a linguistic and model boundary first, not a technical one.
The business is also divided into subdomains, which are classified by their strategic value. This classification guides where the organization invests its best modeling effort.
| Subdomain type | Business role | Typical investment |
|---|---|---|
| Core domain | Source of competitive advantage | Custom code, best engineers, deep modeling |
| Supporting subdomain | Needed but specific to the business | Simpler custom code or outsourcing |
| Generic subdomain | Solved the same way everywhere | Off-the-shelf product or library |
A context map documents how bounded contexts relate to each other. Its patterns describe both technical integration and the power relationship between teams, which often explains why an integration is shaped the way it is.
| Pattern | Meaning | When it fits |
|---|---|---|
| Shared kernel | Two contexts share a small model subset | Closely cooperating teams |
| Customer-supplier | Upstream team plans for downstream needs | Clear dependency with negotiation |
| Conformist | Downstream adopts the upstream model as is | No influence over the upstream |
| Anticorruption layer | Translation layer protects the local model | Integrating legacy or external systems |
| Open host service | Upstream offers a published protocol | Many consumers of one context |
| Separate ways | No integration at all | Integration costs exceed benefits |
Tactical design: the building blocks
Tactical design provides patterns for expressing a model in object-oriented or functional code within a single bounded context. The building blocks separate things with identity from plain values and define where consistency rules are enforced.
| Building block | Defining property | Example |
|---|---|---|
| Entity | Identity persists through changes | Customer with a customer number |
| Value object | Defined only by its attributes, immutable | Money amount with currency |
| Aggregate | Cluster with one root enforcing invariants | Order with its order lines |
| Domain event | Record of something that happened | Order shipped |
| Repository | Collection-like access to aggregates | Order repository |
| Domain service | Operation that belongs to no single object | Currency conversion policy |
| Factory | Encapsulates complex creation | Building a valid insurance policy |
The aggregate is the most consequential of these patterns. It defines a transactional consistency boundary: all invariants inside one aggregate hold after every transaction, while consistency between aggregates is usually eventual, propagated through domain events. Practitioners recommend small aggregates that reference others by identity, because large aggregates cause locking conflicts and slow loading.
DDD compared with related architecture approaches
Domain-driven design is a modeling discipline, not a layering scheme, so it complements rather than competes with most architectural styles. Hexagonal architecture and clean architecture are frequently used to keep a DDD model independent of databases and frameworks.
| Concept | Primary focus | Relation to DDD |
|---|---|---|
| Hexagonal architecture | Isolating the core through ports and adapters | Common host structure for a domain model |
| Clean architecture | Dependency rule pointing inward | Protects the domain layer from frameworks |
| Repository pattern | Abstracting persistence | Adopted as a DDD building block |
| MVC | Separating presentation concerns | Operates at the user interface edge |
| Microservices | Independent deployable services | Bounded contexts often guide service boundaries |
The link to microservices deserves care. A bounded context is a good candidate for a service boundary, yet one context may contain several services, and splitting along technical layers instead of contexts tends to produce a distributed monolith with chatty coupling.
When domain-driven design pays off and when it does not
DDD pays off when business complexity dominates technical complexity and the domain changes over the life of the system. Insurance, logistics, trading, healthcare administration and banking are classic examples, because their rules are numerous, interdependent and frequently revised.
It is poorly suited to simple CRUD applications, reporting tools or thin integration layers, where the full tactical toolkit adds ceremony without benefit. Strategic design, however, remains useful almost everywhere, because clarifying boundaries and vocabulary is cheap and prevents expensive misunderstandings.
- Anemic domain model: entities hold data while all logic lives in services, which defeats the purpose of the model.
- Tactical patterns without strategy: teams adopt aggregates and repositories but never define bounded contexts.
- No access to domain experts: the ubiquitous language is invented by developers alone.
- Oversized aggregates: one aggregate grows to cover a whole subdomain and becomes a bottleneck.
Collaborative techniques such as event storming and domain storytelling help teams discover events, commands and boundaries quickly, often in workshops of a few hours to a few days, before any code is written.
A plain-language summary
Domain-driven design means building software around the business, around how it actually works and talks. Programmers sit down with the people who know the work best, agree on the words they use, and make the program use exactly those words.
Large organizations are split into areas, much like departments in a company, and each area gets its own clear model with its own vocabulary. That way a change in shipping does not accidentally break billing, and everyone understands what the software is supposed to do.
An example from practice
A regional insurance company replaces a 20-year-old policy administration system. In a three-day event storming workshop, underwriters, claims handlers and developers map more than 150 domain events and identify four bounded contexts: underwriting, policy management, claims and billing. Underwriting is classified as the core domain, while billing is a generic subdomain served by a purchased product.
Inside policy management, a Policy aggregate enforces rules such as coverage limits, and changes are announced through events such as PolicyEndorsed. An anticorruption layer translates the old mainframe records into the new model during migration. The result is that rule changes requested by underwriters are implemented in days rather than months, because the code uses their terms and each change stays inside one context.