Model the software around the business: shared language, bounded contexts, aggregates and events.
Domain-Driven Design (DDD) is a way of building software where the code is shaped around the business it serves. You work with the people who know the business (the domain experts) and put their words and rules straight into the code.
Most projects fail to deliver value not because the code is slow, but because developers and the business do not understand each other. The business says "a policy lapses". The code says status = 3. Every question needs a translator, and mistakes hide in the translation.
DDD attacks this problem. You sit with experts, learn their words, and then model the domain in code with the same words. Two groups of ideas make this work. The strategic ideas decide how to cut a big system into parts. The tactical ideas decide how to build the inside of one part.
| Block | Identity? | What it is | Example |
|---|---|---|---|
| Entity | Yes, lasts over time | An object defined by who it is, not by its data | Customer 77, Order 1042 |
| Value object | No, compared by value | A small, unchangeable group of values | Money(5, USD), Address, DateRange |
| Aggregate | Root has an identity | A cluster that is always consistent as a whole | Order with its order lines |
| Repository | n/a | Loads and saves whole aggregates | OrderRepository.find(id) |
| Domain event | n/a | A fact from the past, named in the language of the business | OrderPlaced, PaymentReceived |
| Domain service | n/a | A rule that spans several objects | TransferMoney(from, to) |
| Relationship | Meaning | When to use it |
|---|---|---|
| Customer-supplier | One team supplies, the other consumes, and they agree on needs | Two teams who can plan together |
| Shared kernel | Two contexts share a small piece of model and code | Very close teams, kept deliberately tiny |
| Conformist | The downstream team simply accepts the upstream model | You have no power to change the other side |
| Anti-corruption layer | A translator protects your model from a foreign one | Dealing with a legacy or third-party system |
| Separate ways | No integration at all | The link is not worth the cost |
A teaching example with made-up fields and numbers. Real models are discussed with domain experts and are never this small.
| Term | Meaning in easy words |
|---|---|
| Domain | The business area your software is about |
| Domain expert | A person who knows the business deeply (for example a claims manager) |
| Ubiquitous language | One shared vocabulary used in talks, documents and code |
| Bounded context | A boundary inside which a model and its words keep one clear meaning |
| Subdomain | A part of the business: core, supporting or generic |
| Entity | An object with an identity that lasts while its data changes |
| Value object | An object with no identity, compared by its values and not changed in place |
| Aggregate | A cluster of objects that must always be consistent together |
| Aggregate root | The single entry point of an aggregate, which enforces its rules |
| Domain event | A fact that happened in the business, named in the past tense |
| Context map | A picture of how bounded contexts relate and exchange data |
| Choice | We gain | We lose |
|---|---|---|
| Many small contexts | Independent teams and models | More integration work and duplicated data |
| One big context | Simple, one model to learn | Words become vague and the model turns into a ball of mud |
| Small aggregates | Fewer lock conflicts, easy to scale | Rules across aggregates are eventually consistent |
| Large aggregates | Strong consistency in one transaction | Contention and slow saves under load |
| Full DDD toolkit | Rich, protected model | More code and concepts for a simple problem |
| Plain CRUD | Fast to build | Rules scatter across the app as it grows |