Domain-Driven Design (DDD)
Domain-Driven Design (DDD) is a software development approach aligning
software structure with a business's actual needs and requirements — by
breaking down complex business domains into well-defined components that
map onto the software's own structure, rather than letting the
software's structure drift from how the business actually thinks about
its own domain.
Core concepts
- Ubiquitous language — a shared vocabulary used by both business
stakeholders and the development team, so a term means the same thing
in a stakeholder conversation, in the code, and in documentation.
Divergent vocabulary between business and code is a common, subtle
source of misunderstood requirements — DDD treats fixing this as a
first-class design activity, not just a communication nicety.
- Bounded contexts — a complex business domain is broken into
smaller, more manageable subdomains, each with its own context, rules,
language, and models specific to it. A term can legitimately mean
something different in two different bounded contexts (e.g. "Customer"
might mean something different in a Billing context than in a Support
context) — DDD treats this as expected and manageable, not as an
inconsistency to eliminate everywhere.
- Entities and Value Objects — two key building blocks: an
Entity has a unique identity and can change over time (a specific
customer, an order); a Value Object represents a value or concept
with no independent identity (a date, a currency amount) — two Value
Objects with the same data are interchangeable, while two Entities
with identical data are still distinct if their identities differ.
- Aggregates — a cluster of entities and value objects treated as
one consistency unit, with one designated "root" entity controlling
access to the rest — used to enforce business invariants that must
hold across the whole cluster, not just within one entity.
- Domain events — significant occurrences within the business domain
(a customer placing an order, a product shipping), used to trigger
further actions or processes within the system — a natural fit for
event-driven architectures.
Relationship to structural diagramming
A [[class-diagram]] can express DDD's entities, value objects, and
their relationships in UML notation; a [[package-diagram]] can
express bounded-context boundaries as package boundaries. DDD supplies
the conceptual modeling discipline (what should be an entity, where a
bounded context boundary belongs); these diagram types supply the
notation for documenting the result.
Common pitfalls
- One shared model forced across the whole system — ignoring bounded
contexts and insisting on one universal model for a term like
"Customer" across every subdomain creates a model that's either overly
generic or increasingly contradictory as the system grows.
- Anemic domain models — entities that are just data bags with no
real behavior, with all the actual logic living elsewhere (in services
or controllers), defeats DDD's goal of making the domain model itself
expressive and behavior-rich.
- Ubiquitous language that exists only in documentation, not in code
— if the code's naming diverges from the agreed shared vocabulary, the
ubiquitous language stops actually functioning as a shared
understanding tool.
- Aggregates sized too large — an aggregate spanning too much of the
domain creates unnecessary contention and coupling; aggregates should
be sized to the actual consistency boundary a business invariant
requires, not larger.
Learn more
- Eric Evans, Domain-Driven Design: Tackling Complexity in the Heart of Software — the originating text.
- [[class-diagram]] for notating entities, value objects, and their relationships.
- [[package-diagram]] for notating bounded-context boundaries.
1---2name: domain-driven-design3description: Use when asked to apply Domain-Driven Design (DDD) — ubiquitous language, bounded contexts, entities/value objects, aggregates, domain events — as a software-design approach for aligning code structure with business domain concepts, complementing class-diagram's structural notation and package-diagram's module organization.4metadata:5 source: https://skillmd.com/skills/skills-on-ai/domain-driven-design6---78# Domain-Driven Design (DDD)910Domain-Driven Design (DDD) is a software development approach aligning11software structure with a business's actual needs and requirements — by12breaking down complex business domains into well-defined components that13map onto the software's own structure, rather than letting the14software's structure drift from how the business actually thinks about15its own domain.1617## Core concepts1819- **Ubiquitous language** — a shared vocabulary used by both business20 stakeholders and the development team, so a term means the same thing21 in a stakeholder conversation, in the code, and in documentation.22 Divergent vocabulary between business and code is a common, subtle23 source of misunderstood requirements — DDD treats fixing this as a24 first-class design activity, not just a communication nicety.25- **Bounded contexts** — a complex business domain is broken into26 smaller, more manageable subdomains, each with its own context, rules,27 language, and models specific to it. A term can legitimately mean28 something different in two different bounded contexts (e.g. "Customer"29 might mean something different in a Billing context than in a Support30 context) — DDD treats this as expected and manageable, not as an31 inconsistency to eliminate everywhere.32- **Entities and Value Objects** — two key building blocks: an33 **Entity** has a unique identity and can change over time (a specific34 customer, an order); a **Value Object** represents a value or concept35 with no independent identity (a date, a currency amount) — two Value36 Objects with the same data are interchangeable, while two Entities37 with identical data are still distinct if their identities differ.38- **Aggregates** — a cluster of entities and value objects treated as39 one consistency unit, with one designated "root" entity controlling40 access to the rest — used to enforce business invariants that must41 hold across the whole cluster, not just within one entity.42- **Domain events** — significant occurrences within the business domain43 (a customer placing an order, a product shipping), used to trigger44 further actions or processes within the system — a natural fit for45 event-driven architectures.4647## Relationship to structural diagramming4849A [[class-diagram]] can express DDD's entities, value objects, and50their relationships in UML notation; a [[package-diagram]] can51express bounded-context boundaries as package boundaries. DDD supplies52the *conceptual* modeling discipline (what should be an entity, where a53bounded context boundary belongs); these diagram types supply the54*notation* for documenting the result.5556## Common pitfalls5758- **One shared model forced across the whole system** — ignoring bounded59 contexts and insisting on one universal model for a term like60 "Customer" across every subdomain creates a model that's either overly61 generic or increasingly contradictory as the system grows.62- **Anemic domain models** — entities that are just data bags with no63 real behavior, with all the actual logic living elsewhere (in services64 or controllers), defeats DDD's goal of making the domain model itself65 expressive and behavior-rich.66- **Ubiquitous language that exists only in documentation, not in code**67 — if the code's naming diverges from the agreed shared vocabulary, the68 ubiquitous language stops actually functioning as a shared69 understanding tool.70- **Aggregates sized too large** — an aggregate spanning too much of the71 domain creates unnecessary contention and coupling; aggregates should72 be sized to the actual consistency boundary a business invariant73 requires, not larger.7475## Learn more7677- Eric Evans, *Domain-Driven Design: Tackling Complexity in the Heart of Software* — the originating text.78- [[class-diagram]] for notating entities, value objects, and their relationships.79- [[package-diagram]] for notating bounded-context boundaries.