7.1 · Why DDD
Published by Eric Evans in 2003 (Domain-Driven Design: Tackling Complexity in the Heart of Software), DDD answers a specific class of project failure: software that is technically excellent but does not capture how the business actually works. DDD pays off when business complexity dwarfs technical complexity. For a CRUD over a database it is overkill; for insurance underwriting, supply chains, healthcare claims, payments switching, telco mediation, or marketplace pricing it is often the only thing that works.
Vaughn Vernon's Implementing Domain-Driven Design (2013, the "red book") and Domain-Driven Design Distilled (2016) made the discipline practical; Vlad Khononov's Learning Domain-Driven Design (2021) refreshed it for modern microservice contexts.
7.2 · Strategic DDD
The strategic layer carves the problem domain into bounded contexts — explicit boundaries within which a single Ubiquitous Language is precise and unambiguous. The same word ("Customer", "Order", "Account") often means different things in different contexts; strategic DDD makes the differences visible instead of papering over them.
Context Maps — the nine relationship patterns
| Pattern | Meaning |
|---|---|
| Partnership | Two teams succeed or fail together; coordinated planning, mutual dependency. |
| Shared Kernel | Two contexts share a small, agreed-upon subset of the model; changes need bilateral consent. |
| Customer / Supplier | Upstream supplier accepts downstream customer's needs in its backlog. |
| Conformist | Downstream accepts upstream's model as-is; no negotiation power. |
| Anti-Corruption Layer (ACL) | Translation façade that keeps a foreign / legacy model from leaking inward. |
| Open Host Service (OHS) | Published protocol any consumer may use; stable, generic interface. |
| Published Language | Shared, well-documented schema (e.g. industry standard) used between contexts. |
| Separate Ways | Integration cost is higher than value; the contexts simply don't talk. |
| Big Ball of Mud | The honest label for legacy systems with no boundaries; isolate behind ACL. |
7.3 · Tactical DDD — the building blocks
Inside a bounded context, DDD provides a small, opinionated set of building blocks. Used together they keep the domain model expressive and the infrastructure at arm's length.
| Block | Definition |
|---|---|
| Entity | Has identity that persists through state changes (Customer #1234 is the same entity even if the name changes). |
| Value Object | Defined entirely by its attributes; immutable; no identity (Money, Address, DateRange). |
| Aggregate | Consistency boundary: a cluster of entities + value objects treated as a single unit. The Aggregate Root is the only external entry point. All invariants inside hold at the end of every transaction. |
| Domain Service | Business behaviour that doesn't naturally belong to a single entity (e.g. FundsTransfer across two accounts). |
| Application Service | Thin orchestration layer above the domain; coordinates use-cases, transactions, security; holds no business rules. |
| Repository | Collection-like abstraction for retrieving and persisting aggregate roots. Hides the persistence mechanism. |
| Factory | Encapsulates complex aggregate construction so the rest of the model stays simple. |
| Domain Event | An immutable fact about something the domain has decided (OrderPlaced, PaymentCaptured). Past tense, named in the Ubiquitous Language. |
// Aggregate boundary in Kotlin (tactical DDD) class Order private constructor( val id: OrderId, private val lines: MutableList<OrderLine>, private var status: OrderStatus ) { fun addLine(sku: Sku, qty: Int): DomainEvent { require(status == OrderStatus.DRAFT) { "only DRAFT orders may change" } lines += OrderLine(sku, qty) return OrderLineAdded(id, sku, qty) } }
7.4 · EventStorming — Alberto Brandolini
EventStorming (2013) is a fast, low-tech workshop format using coloured sticky notes on a wall (or virtual whiteboard) to map a business process. There are three levels of fidelity:
- Big Picture — explore the whole business, surface chaos, find hot spots.
- Process Modelling — for a chosen slice, add commands, actors, policies, read models.
- Software Design — refine until aggregates and bounded contexts emerge.
| Colour | Sticky meaning |
|---|---|
| Orange | Domain Event (past tense — "OrderPlaced") |
| Blue | Command (imperative — "PlaceOrder") triggered by an actor |
| Yellow | Aggregate (state on which a command acts) |
| Pink | External system |
| Purple | Policy (whenever X happens, do Y) |
| Green | Read model / view used to make a decision |
| Red | Hot spot — a question, conflict, or known unknown |
7.5 · Event Modeling — Adam Dymitruk
Event Modeling (2018) is a more rigorous, swimlane-based descendant of EventStorming. The board is divided into vertical slices — each a single user-visible workflow — and horizontal swimlanes (UI, command, event, read model). It is particularly well-suited to systems that will use Event Sourcing + CQRS because the model maps almost 1-to-1 to implementation. Where EventStorming explores, Event Modeling specifies.
7.6 · Subdomain types — Core, Supporting, Generic
| Type | Definition | Investment strategy |
|---|---|---|
| Core | Competitive differentiator; the reason customers pay you | Build in-house, best engineers, deepest DDD modelling |
| Supporting | Necessary but not differentiating | Build pragmatically, or buy if a good fit exists |
| Generic | Solved problem available off-the-shelf (auth, billing, search) | Buy / SaaS; never build |
7.7 · Sizing bounded contexts
"One bounded context per microservice" is a heuristic, not a rule. The right size is determined by: (a) consistency requirements — what must change atomically lives together; (b) team topology — Conway's Law; (c) rate of change — features that ship together belong together; (d) data volume and access patterns. A context can legitimately be a modular monolith, a single service, or a small constellation of services. The boundary is the language boundary, not the deployment boundary.
Context Map — three bounded contexts
7.8 · DDD & microservices
Microservices and DDD reinforce each other when used together correctly: each service owns one bounded context (or part of one) and exposes its Ubiquitous Language through an Open Host Service or Published Language. The classic mistake is technical decomposition — splitting by layer (auth-service, db-service, ui-service) or by entity (user-service, order-service, product-service) instead of by business capability. The result: every business operation requires a chatty orchestration across many services, and a single domain change ripples through all of them.
7.9 · Common DDD anti-patterns
- Anemic Domain Model (Fowler 2003) — entities are bags of getters/setters; all behaviour lives in services. The "domain" model is a data structure pretending to be a model.
- God Aggregate — one aggregate root tries to enforce every invariant in the system; performance and merge-conflict nightmares follow.
- Infrastructure leaking into the domain — domain classes import JPA annotations, HTTP frameworks, or message-broker clients. Use Hexagonal (Ch 06) to keep the centre clean.
- Ignoring the Ubiquitous Language — code uses different words from the business ("User" in code, "Member" in conversation); knowledge bleeds out at every handoff.
- Premature tactical DDD — adopting aggregates and value objects without first establishing bounded contexts. The patterns are local; the strategy is global.
- One context = one service, always — converts a useful heuristic into a religion; produces over-decomposed systems.