When is domain-driven design worth it?
DDD pays off when the business rules are the hard part and several teams or departments use the same words to mean different things. For CRUD apps it's mostly ceremony. Which parts to take (language, bounded contexts) even on small projects, and which to skip.
Short answer: the verdict, as the cases below will show: take the cheap parts of DDD everywhere, and the expensive parts only where the domain is complex.
- Always worth it: a shared vocabulary with the business (the ubiquitous language) and clear boundaries between parts of the system that mean different things by the same word (bounded contexts).
- Worth it for complex rules: aggregates that protect invariants, domain events, and a domain model kept free of database and HTTP code.
- Usually not worth it: the full tactical toolkit (repositories, factories, value objects, domain services and application services for everything) on an app that mostly stores and shows forms.
The case often starts with an invoice that’s wrong, and nobody can say why. Sales thought the order was a draft; finance thought it was confirmed; the code had one Order table trying to be both. The idea at the heart of Eric Evans’s book is a humane one: the hardest bugs live in misunderstandings, so the code should speak the same language as the people who know the business. Once you see that, the rest of DDD becomes much easier to pick and choose from.
Case file
The case An invoice is wrong, and nobody can say why Suspects Not enough patterns, too many patterns Culprit One Ordertable trying to mean a draft to sales and a commitment to financeThe fix Shared language and bounded contexts everywhere, tactical patterns only where the rules are complex
What DDD actually is #
Domain-driven design is two things that often get mixed up, and the confusion is half the mystery:
| Strategic DDD | Tactical DDD | |
|---|---|---|
| About | Where the boundaries go and what words mean | How to structure code inside one boundary |
| Main ideas | Ubiquitous language, bounded contexts, context maps, core vs supporting vs generic subdomains | Entities, value objects, aggregates, domain events, repositories |
| Cost | Conversations and naming; little code | A lot of code and indirection |
| Payoff | Fewer misunderstandings; services and modules split in the right places | Rules enforced in one place, testable without a database |
Here’s the reveal hiding in that table. Most of DDD’s value is strategic, which I find rather encouraging: the most useful parts are mostly conversations. Most of its reputation for ceremony comes from tactical patterns applied everywhere.
Case 1: a B2B order and pricing domain #
The situation: a distributor takes orders by email, spreadsheet and portal. “Order” means a draft to sales, a confirmed commitment to finance, and a pick list to the warehouse. Prices depend on customer tier, contract, volume and currency, and mistakes cost money.
What I’d do: full DDD, at least in the pricing and ordering core.
- Language: agree what quote, order, confirmed order, line and allocation mean, and use exactly those words in code, tables and tickets.
- Bounded contexts: this is the most valuable step, because it stops one word from being forced to mean four things. Sales (quotes, drafts), Ordering (confirmed orders and their invariants), Fulfilment (picks, shipments), Billing. Each has its own model of an order; they talk through events like
OrderConfirmed, not shared tables. - Aggregates: an
Orderaggregate guarantees that its total equals the sum of its lines, that a confirmed order can’t gain lines, and that it can only move through allowed states. All changes go through it. There’s a quiet elegance in that: a whole class of wrong invoices simply can’t be written.
The document ingestion lab is a small version of the front end of this: messy documents become structured orders checked against a catalogue, and anything uncertain is routed to a person. The catalogue and the order are different contexts with different rules.
Diagram source
flowchart LR
S["Sales: quotes, drafts"] -->|"order agreed"| O["Ordering: confirmed orders"]
O -->|"OrderConfirmed"| F["Fulfilment: picks, shipments"]
O -->|"OrderConfirmed"| B["Billing: invoices"]
Case 2: a content site or a simple SaaS dashboard #
The situation: a blog platform, a CMS, an admin panel. The data is mostly what users typed, and the rules are validation plus permissions.
What I’d do: skip tactical DDD. Keep the language and the boundaries.
- The blogging platform I run has two clear contexts: publishing (blogs, posts, revisions) and engagement (readers, comments, likes, subscriptions). They live in separate files and tables, and “reader” never leaks into the writer’s account model.
- But there are no aggregates or repositories as classes. The
storepackage has plain functions that run SQL, and the database (constraints, row-level security) enforces the invariants that matter.
This is where the full toolkit turns into a false lead. Wrapping each table in an entity, a repository interface and a repository implementation would add three files per concept and catch no extra bugs.
Case 3: splitting a monolith #
This is where strategic DDD shows its worth. The situation: a monolith has grown, deploys are slow, and teams step on each other. Someone proposes microservices.
What I’d do: use bounded contexts to choose the seams before choosing the deployment shape.
- Map the contexts and the language each one uses. Seams usually sit where the same word changes meaning. That’s the clue to follow: listen for the word that shifts.
- Make them modules inside the monolith first, with their own tables and no cross-module joins.
- Split a module into a service only when it needs to scale, deploy or fail independently. The monolith, microservices or cells post covers that choice.
Splitting along technical layers (“the database service”, “the API service”) or along nouns (“the customer service”) without understanding the contexts is how you get a distributed monolith.
Clues that you need more DDD #
- Bugs come from misunderstood rules, not from crashes.
- The same field means different things to different teams (
status,amount,customer). - Business experts can’t read or review the names in your code.
- One change to a rule touches many files because the rule is spread out.
Clues that you’re overdoing it #
- Every table has an entity, a repository interface, an implementation and a mapper, and they all look the same.
- “Domain services” that only call a repository.
- Aggregates that span half the database, so every write locks everything.
- More time spent arguing about whether something is an entity or a value object than talking to the business.
Remember this
- Most of DDD’s value is strategic: shared words and clear boundaries.
- Seams sit where the same word changes meaning.
- Skip the tactical toolkit where the code mostly stores and shows data.
Case closed: what I’d do by default #
- Name things the way the business does, and keep a short glossary in the repo.
- Draw the bounded contexts even for a small system; make them modules with their own tables.
- Put invariants in one place: an aggregate for complex rules, a database constraint for simple ones.
- Communicate between contexts with events or narrow APIs, not shared tables.
- Skip the tactical patterns where the code is mostly storing and showing data.
At its best, DDD feels less like a methodology and more like good listening: you learn how the business thinks, and the code becomes a faithful, readable picture of it.
Comments
No comments yet.
Sign in to comment. We'll email you a link; no password needed.