Domain-Driven Design
Subject: Computer and Technology noun /doʊˈmeɪn ˈdrɪv.ən dɪˈzaɪn/ 1 definition
- software-architecture
- software-engineering
- system-design
- domain-modeling
-
Definition (noun)
Entry #269 · UpdatedDomain-Driven Design (DDD) is a software design methodology, formalized by Eric Evans, that aligns system architecture and code with the structure, rules, and terminology of the underlying business domain. Rather than organizing software primarily around database schemas or technical frameworks, developers and domain experts collaborate to establish a shared ubiquitous language that maps directly into domain models composed of entities, value objects, aggregates, and domain events. At a strategic level, DDD divides large systems into explicit bounded contexts linked by context maps and anti-corruption layers so models can evolve independently without semantic ambiguity. Its primary boundary and purpose lie in isolating core business invariants from infrastructure concerns in complex domains, whereas simpler CRUD applications rarely justify its modeling overhead.
Common Forms
Strategic Design: Decomposes large problem spaces into core, supporting, and generic subdomains, isolating each model inside a bounded context and defining explicit integration contracts through context maps and anti-corruption layers.
Tactical Design: Models business behavior within a single bounded context using concrete code patterns—including entities, immutable value objects, consistency-enforcing aggregates, repositories, and domain services—to protect invariants.
Hexagonal and Onion Architecture: Isolates the domain layer at the center of an application behind abstract ports and repositories, ensuring databases, message brokers, and API controllers depend on the domain rather than coupling business rules to infrastructure.
Event-Driven and Event-Sourced DDD: Captures meaningful state changes as immutable domain events raised by aggregates, enabling loosely coupled synchronization across bounded contexts and supporting event sourcing or CQRS read projections.
Example
In a retail platform structured with DDD, the
Salesbounded context enforces order pricing and discount invariants inside anOrderaggregate root—validatingapplyDiscount(code, amount)against immutableMoneyvalue objects before committing to PostgreSQL—while theShippingbounded context models the same order ID purely as aShipmentdispatch target. Once payment clears,Salesemits anOrderConfirmedJSON event to an Apache Kafka topic, whichShippingconsumes through an anti-corruption layer to schedule parcel routing without sharing database tables or domain classes.