Domain-Driven Design

Layers of Management ThoughtLayer 8: Methodologies and Operating SystemsMethodologyAlso known as DDD, Domain Driven Design

Developed by Eric Evans and set out in his book Domain-Driven Design: Tackling Complexity in the Heart of Software (Addison-Wesley, 2003), with definitions and pattern summaries in his Domain-Driven Design Reference (2015).

An approach to building complex software in which developers and domain experts build one model of the business together, speak one language inside an explicit boundary, and put their best effort into the core of the business.

Six statements about customers and orders, placed in the bounded context where each is true

Each team uses the same words with its own meaning, and in Domain-Driven Design a model is valid only inside its bounded context. Select a statement, then the context where it holds: the box lights and gives that team's model. Show the sort to compare yours. Illustrative.

Items (select one, then a box)
  • Not placedPlacedSalesBillingSupport
  • Not placedPlacedSalesBillingSupport
  • Not placedPlacedSalesBillingSupport
  • Not placedPlacedSalesBillingSupport
  • Not placedPlacedSalesBillingSupport
  • Not placedPlacedSalesBillingSupport

Statements

Customer and order
Sales
Billing
Support
SalesBillingSupport

Bounded context

Customer: open quote. A person the sales team is talking to, who has not bought anything yet.Not placed yet.Customer: open quote. A person the sales team is talking to, who has not bought anything yet.Sales: The sales team's model: a customer is a prospect with a quote, and an order is a signed quote. It lives and changes with sales.True for sales. In billing there is no invoice yet, so the same word there would mean nobody.Customer: open quote. A person the sales team is talking to, who has not bought anything yet.Billing: Finance's model: a customer is the legal entity on an invoice, and an order is a charge to collect. It must stay exact.Customer: open quote. A person the sales team is talking to, who has not bought anything yet.Support: The support team's model: a customer is anyone with a ticket, and an order is a past purchase to look up.Order: a signed quote. The moment a quote becomes a deal.Not placed yet.Order: a signed quote. The moment a quote becomes a deal.Sales: The sales team's model: a customer is a prospect with a quote, and an order is a signed quote. It lives and changes with sales.A sales fact. Billing would call the same event the start of a charge.Order: a signed quote. The moment a quote becomes a deal.Billing: Finance's model: a customer is the legal entity on an invoice, and an order is a charge to collect. It must stay exact.Order: a signed quote. The moment a quote becomes a deal.Support: The support team's model: a customer is anyone with a ticket, and an order is a past purchase to look up.Customer: invoiced entity. The legal entity named on an invoice, with a tax number.Not placed yet.Customer: invoiced entity. The legal entity named on an invoice, with a tax number.Sales: The sales team's model: a customer is a prospect with a quote, and an order is a signed quote. It lives and changes with sales.Customer: invoiced entity. The legal entity named on an invoice, with a tax number.Billing: Finance's model: a customer is the legal entity on an invoice, and an order is a charge to collect. It must stay exact.Billing must be exact here. If sales changed it to suit a prospect, invoices would break.Customer: invoiced entity. The legal entity named on an invoice, with a tax number.Support: The support team's model: a customer is anyone with a ticket, and an order is a past purchase to look up.Order: a charge to collect. An amount owed, with a due date.Not placed yet.Order: a charge to collect. An amount owed, with a due date.Sales: The sales team's model: a customer is a prospect with a quote, and an order is a signed quote. It lives and changes with sales.Order: a charge to collect. An amount owed, with a due date.Billing: Finance's model: a customer is the legal entity on an invoice, and an order is a charge to collect. It must stay exact.A finance fact that must stay exact, whatever the other teams call an order.Order: a charge to collect. An amount owed, with a due date.Support: The support team's model: a customer is anyone with a ticket, and an order is a past purchase to look up.Customer: has a ticket. Anyone with an open issue, buyer or not.Not placed yet.Customer: has a ticket. Anyone with an open issue, buyer or not.Sales: The sales team's model: a customer is a prospect with a quote, and an order is a signed quote. It lives and changes with sales.Customer: has a ticket. Anyone with an open issue, buyer or not.Billing: Finance's model: a customer is the legal entity on an invoice, and an order is a charge to collect. It must stay exact.Customer: has a ticket. Anyone with an open issue, buyer or not.Support: The support team's model: a customer is anyone with a ticket, and an order is a past purchase to look up.True for support. Billing would reject someone with no account.Order: a purchase to find. A past purchase the agent looks up to help.Not placed yet.Order: a purchase to find. A past purchase the agent looks up to help.Sales: The sales team's model: a customer is a prospect with a quote, and an order is a signed quote. It lives and changes with sales.Order: a purchase to find. A past purchase the agent looks up to help.Billing: Finance's model: a customer is the legal entity on an invoice, and an order is a charge to collect. It must stay exact.Order: a purchase to find. A past purchase the agent looks up to help.Support: The support team's model: a customer is anyone with a ticket, and an order is a past purchase to look up.A lookup for support. It needs no billing rules and no deal stages.

Your sort matched 0 of 6.Your sort matched 1 of 6.Your sort matched 2 of 6.Your sort matched 3 of 6.Your sort matched 4 of 6.Your sort matched 5 of 6.Your sort matched 6 of 6.

Sales
The sales team's model: a customer is a prospect with a quote, and an order is a signed quote. It lives and changes with sales.
Billing
Finance's model: a customer is the legal entity on an invoice, and an order is a charge to collect. It must stay exact.
Support
The support team's model: a customer is anyone with a ticket, and an order is a past purchase to look up.

The sort

  • Customer: open quote: Sales. True for sales. In billing there is no invoice yet, so the same word there would mean nobody.
  • Order: a signed quote: Sales. A sales fact. Billing would call the same event the start of a charge.
  • Customer: invoiced entity: Billing. Billing must be exact here. If sales changed it to suit a prospect, invoices would break.
  • Order: a charge to collect: Billing. A finance fact that must stay exact, whatever the other teams call an order.
  • Customer: has a ticket: Support. True for support. Billing would reject someone with no account.
  • Order: a purchase to find: Support. A lookup for support. It needs no billing rules and no deal stages.

An example

A distributor's order system had grown for fifteen years, and every change broke something elsewhere. The word customer meant a prospect with an open quote to the sales team, the legal entity on an invoice to finance, and anyone with an open ticket to support. The one shared customer table carried all three meanings, and a change to suit one team broke the other two.

The architect brought the three teams and their developers into a room and had each describe its customer in its own words. They drew three bounded contexts, sales, billing, and support, each with its own model, and agreed how the contexts would pass information to each other. Billing's model became the home of the legal entity. Support stopped asking for changes to a table it did not own. Within a quarter, releases that touched customers stopped causing incidents in the other teams' work, and requests that once took weeks of negotiation took days.

The core idea

Domain-Driven Design starts from where the difficulty in most business software lives: in the business itself, the rules, exceptions, and meanings developers have to get right. Evans compresses the answer into three moves. Put the best design effort into the core domain, the part of the business that sets the company apart, and keep the rest simple. Build the model of that domain together with the people who do the work, in repeated rounds of sketching and testing. And use one precise vocabulary, the ubiquitous language, in conversation, documents, and code alike.

The language holds only inside a bounded context, an explicit boundary, often one team's subsystem, within which every term has a single meaning. That is the method's key move. A large project always ends up with several models, and trouble starts when code built on different models is mixed without anyone saying so. DDD draws the boundaries on purpose and maps how the contexts exchange information, so each model can stay sharp.

The thinking behind it

Eric Evans Eric Evans, founder of the consultancy Domain Language, published Domain-Driven Design: Tackling Complexity in the Heart of Software with Addison-Wesley in August 2003. Its argument is that the model of the business should not live apart from the code: the experts' vocabulary, the design, and the code should be one thing that changes together. The book runs in four parts: the model and its shared language, design that keeps code and model in step, refactoring as the team's understanding deepens, and strategic design for large systems, where bounded contexts and the core domain come in. In 2015 he published a short reference of definitions and pattern summaries under a Creative Commons license.

Where it sits in the layers

Domain-Driven Design sits in Layer 8, Methodologies and Operating Systems, because it is a bundled approach with its own vocabulary, patterns, and ways of working between technical and business people. It takes for granted the view of Modularity Theory in Layer 3 that complex systems divide into parts with defined interfaces, and the observation in Conway's Law in Layer 5 that software structure follows the structure of the teams that build it. Below it, the C4 Model in Layer 9 draws what it decides, and Layer 10 routines such as code review keep the language honest, catching a term used against its context's meaning. The common mistake is to apply it to a simple domain. DDD pays off where the business logic is complicated and changes often, and it adds cost to routine record-keeping.

How organizations put it to work

An organization adopts DDD in its software groups, usually led by an architect or a senior engineer who works with business experts. The change is first in how requirements are discovered. Developers and domain experts model together, and the shared language shows up in the code, the documents, and the meeting talk. It then changes structure: the boundaries between contexts become the boundaries between teams and services, and a context map records how they relate.

It changes where effort goes. Evans's priority is the core domain, the part that makes the business distinctive, so the best developers work on it first, and generic parts are bought or built simply. Measures follow: how often the business and technical vocabularies diverge, how many changes cross a context boundary, and how long a change in the core takes.

Sustaining it takes domain experts who keep giving time, a team willing to refactor the model as it learns, and discipline about boundaries. In the first year a leader should expect slow early sessions, some argument over where one context ends, and a clearer view of which parts of the system matter most. The business depends less on the few developers who understand the tangle, and its changes become safer.

Where it goes wrong

The first failure is the technical vocabulary without the business conversation. Teams adopt the patterns, entities, aggregates, and repositories, and never sit down with domain experts. The sign is a code model that experts cannot read.

The second is one model for everything. Teams try to unify a single enterprise model across contexts, and the compromises make it fit nobody. Evans's own point is that multiple models are inevitable. The sign is a shared table or class that every team is afraid to change.

The third is overreach. DDD applied to a simple, stable domain adds ceremony and delay. The sign is a heavy model for a form that stores and retrieves records.

A further criticism is the cost of entry: the vocabulary is large, and the practice depends on skilled people. The sign is a team still learning patterns months in, with no context drawn. Starting with the core domain and a few contexts keeps the cost in proportion.

Related and rival frameworks

  • C4 Model. A way to draw and share the structure of a system at four levels of zoom. Use it to document what DDD decides, since DDD gives the boundaries and C4 gives the pictures.
  • Team Topologies. Shapes teams around flows of work and limits what each team must hold in mind. The better pick for organizing teams, which can follow the bounded contexts that DDD finds.
  • Reactive Manifesto. States qualities of a system under load and failure. It complements DDD, which says how to divide the business logic, with requirements for how the parts behave when demand shifts.

Go to the source

Back to the catalog