Reference · DDD glossary of terms

DDD glossary of terms

An academic dictionary of the main Domain-Driven Design terms, from strategic patterns and tactical building blocks to architectural and integration patterns. The definitions draw on the primary literature (Evans 2003, Vernon 2013).

Author M. Katuščák
Published · Updated ·
In this chapter

01 Strategic DDD patterns

What are strategic patterns?

Strategic patterns divide a system into cohesive parts and name the relationships between them. They answer the question “what and where”: where the model boundaries lie, who is responsible for which part of the domain, and how the parts communicate. The tactical building blocks stand on this foundation. Without it, they are a random collection of patterns.

Domain

The sphere of knowledge and activity that the application’s logic revolves around. The domain is the “why” of the software: the problem space it models and helps solve. Eric Evans defines the domain as “A sphere of knowledge, influence, or activity. The subject area to which the user applies a program.” The domain is not the application itself. It exists without software, and software is only one of the means of working in it. Without understanding the domain, nobody designs a meaningful model for it.

Source: Eric Evans, Domain-Driven Design (2003)

Subdomain

A part of the overall domain, delimited in the problem space. Subdomains come out of domain analysis, which splits the problem space into cohesive areas. The book distinguishes three types: the Core Domain brings a competitive advantage, a Supporting Subdomain is needed to operate but brings no advantage, and a Generic Subdomain is covered by an off-the-shelf product. Subdomains belong to the problem space; Bounded Contexts are their counterpart in the solution space. One Bounded Context usually implements one subdomain, but a 1:1 ratio is not a rule.

Source: Eric Evans, Domain-Driven Design (2003), ch. 15; Vaughn Vernon, Implementing Domain-Driven Design (2013), ch. 2

Core Domain

The subdomain that brings the greatest competitive advantage. This is where the organization sets itself apart from competitors and where the main reason for building the software lies. It gets the largest investment, the most experienced developers, and the full set of tactical DDD patterns. The other subdomains support it; they are not goals in themselves. Identifying the Core Domain is one of the main outputs of strategic analysis.

Source: Eric Evans, Domain-Driven Design (2003), ch. 15; Vaughn Vernon, Implementing Domain-Driven Design (2013), ch. 2

Supporting Subdomain

A subdomain without which the Core Domain does not work, but which brings no competitive advantage of its own. Example: order tracking in an online store that differentiates itself through its recommendation system. Supporting subdomains are usually built in-house, though without the full set of tactical patterns, because their complexity does not call for it. They are necessary, not strategic. Where an off-the-shelf solution can replace them, that tends to be the cheaper route.

Source: Vaughn Vernon, Implementing Domain-Driven Design (2013), ch. 2

Generic Subdomain

A subdomain whose needs an off-the-shelf solution covers. Examples: authentication and identity management (Keycloak, Auth0), payments (Stripe), and sending email (Mailgun, SendGrid). None of this is specific to a particular business; thousands of organizations solve the same problem. Building it in-house therefore usually wastes capacity. A sensible strategy is to buy, rent, or adopt an existing product. Authorization rules over your own entities, however, stay in the context that uses them.

Source: Eric Evans, Domain-Driven Design (2003), ch. 15; Vaughn Vernon, Implementing Domain-Driven Design (2013), ch. 2

Ubiquitous Language

A shared, precise language of developers and domain experts. The team uses it consistently in code, in conversations, in documentation, in tests, and in diagrams. Its words are terms from the domain, not technical terms or database slang. The language stops being valid at the boundary of the Bounded Context: the same word can mean something else in another context (for example, “customer” in sales and in support). Evans puts it at the foundation of the whole approach. Without a shared language, DDD shrinks to a set of technical patterns.

Source: Eric Evans, Domain-Driven Design (2003), ch. 2

Bounded Context

An explicit boundary inside which one domain model and its Ubiquitous Language apply. Every term inside it has one precise meaning. Another Bounded Context can use the same word for a different concept without the models contradicting each other. It is a logical boundary of the model and the language. In code, one module usually reflects it (in Symfony, a namespace such as App\Ordering). Operationally, a context can run in a modular monolith or as a separate service. Mapping to teams, database schemas, and deployment is a separate decision; the equation “Bounded Context = microservice” is a shortcut, not a definition.

Source: Eric Evans, Domain-Driven Design (2003), ch. 14; Vaughn Vernon, Implementing Domain-Driven Design (2013), ch. 2

Context Map

A document or diagram that shows all Bounded Contexts in a system and the relationships between them. It is not primarily a technical artifact. A Context Map captures team relationships, the direction of dependencies (who depends on whom), integration contracts, and the patterns in use (Shared Kernel, Customer/Supplier, Anti-Corruption Layer, and others). It tends to be the first tangible output of strategic analysis. It shows the actual state, not the one the team wishes for.

Source: Eric Evans, Domain-Driven Design (2003), ch. 14

Partnership

A symmetric relationship between two Bounded Contexts whose teams succeed or fail together. The models stay separate, but planning does not: the teams coordinate development, align releases, and manage the integration jointly. Such a relationship usually emerges on its own, and the Context Map only gives it a name and a process. Evans adds a test suite that verifies in continuous integration that the interface matches the other side’s expectations.

Source: Eric Evans, Domain-Driven Design Reference (2015)

Shared Kernel

A symmetric relationship in which two or more Bounded Contexts share an explicitly delimited subset of the domain model, including its code. Evans does not restrict what the kernel contains. In practice, though, it is kept small, typically just elementary value objects (Money, Currency). Every change must be approved by all owners and pass the tests of all contexts. Tight coupling has its price, so a kernel pays off only where the benefit of sharing outweighs the cost of coordination. A shared technical library (a logger, an HTTP client) is not a Shared Kernel. The App\SharedKernel namespace in the book’s examples also holds technical base types (bus interfaces, abstract classes). Only its domain part forms a Shared Kernel in Evans’s sense.

Source: Eric Evans, Domain-Driven Design (2003), ch. 14

Customer/Supplier

An asymmetric relationship in which a downstream context (the customer) depends on an upstream context (the supplier). Unlike a Conformist, the downstream has a voice: its requirements are negotiated, budgeted, and placed in the supplier’s backlog. The supplier, however, decides when and how to deliver them. The pattern assumes the teams plan together regularly. When the supplier stops taking the customer’s needs into account, the relationship slides toward Conformist, or the downstream builds an Anti-Corruption Layer.

Source: Eric Evans, Domain-Driven Design (2003), ch. 14

Conformist

A downstream role in an asymmetric relationship: the downstream deliberately gives up its own model and adopts the upstream model 1:1, without translation. It is chosen where the upstream team has no reason to accommodate the downstream and its model is good enough for the downstream. A Conformist saves a translation layer and pays for it with dependency on a foreign model. The opposite downstream choice is an Anti-Corruption Layer. Conformist suits a reporting or pass-through context that only displays or forwards data, as well as industry or regulatory formats. Once domain rules of its own rest on the adopted data, the boundary needs an ACL. That is why the book connects both payments (Stripe) and identity (Auth0) through an ACL.

Source: Eric Evans, Domain-Driven Design (2003), ch. 14

Anti-Corruption Layer (ACL)

The role of a downstream that protects itself from a foreign model with an isolating layer. An ACL separates a Bounded Context from the models of other contexts, legacy systems, or external APIs. It translates the terms of the foreign model into its own Ubiquitous Language, validates inputs, and filters out invalid states before they reach the domain. This keeps foreign concepts from “corrupting” the domain model. It is implemented as a set of adapters, facades, and translators at the context boundary. Of all the roles, it is the most frequently used.

Source: Eric Evans, Domain-Driven Design (2003), ch. 14

Open Host Service (OHS)

The role of an upstream that openly publishes a stable, documented protocol for many downstream consumers. Instead of a separate integration agreement with each consumer, it maintains one public protocol, and the downstreams adapt to it. They do not need access to the upstream’s internal model. It pays off from roughly three consumers onward and in a stable domain. The needs of a single team are handled by a one-off translator, so the shared protocol stays small and cohesive.

Source: Eric Evans, Domain-Driven Design (2003), ch. 14

Published Language (PL)

A well-documented, formally specified message format between Bounded Contexts, independent of language, framework, and database. It is often an industry standard (HL7 in healthcare, FIX in finance, ISO 20022 in banking) or a custom JSON Schema or OpenAPI specification. The exchange format should not be the domain model of one of the contexts directly. Every model change would then alter the public contract. Published Language is usually combined with Open Host Service: OHS is the channel, PL the format.

Source: Eric Evans, Domain-Driven Design (2003), ch. 14

Separate Ways

A strategic decision that two Bounded Contexts will not be integrated at all. Each team solves the problem on its own and accepts duplicated data or parallel processes. It fits where integration would cost more than it brings: the shared function is not critical for either context, or communication between the teams is stuck. Separate Ways is a deliberate choice, not a design failure. Duplication comes out cheaper than coordination here.

Source: Eric Evans, Domain-Driven Design (2003), ch. 14

Big Ball of Mud

An anti-pattern: a state of decay in which every context talks to every other one “somehow” and shares database tables, entities, and ad hoc service layers with it. Nobody can point to the model boundaries, the relationships have no names, and so no Context Map can be drawn. Brian Foote and Joseph Yoder introduced the term (1997). In the DDD Reference, Evans lists it as a ninth item next to the eight Context Mapping patterns. Unlike them, nobody chooses it deliberately: it emerges when a team makes no choice at all.

Source: Brian Foote & Joseph Yoder, Big Ball of Mud (1997); Eric Evans, Domain-Driven Design Reference (2015)

02 Tactical patterns (DDD building blocks)

What are tactical patterns?

Tactical patterns are the object-oriented building blocks used to implement a domain model inside a single Bounded Context. They answer the question “how”: how to model an entity, enforce invariants, keep state, and express domain operations. They make sense only inside a strategic frame that determines where the model applies.

Entity

A domain object with a unique, persistent identity that sets it apart even when all its attributes change. Example: a user identified by a UserId value remains the same entity even after changing their name, email, and address. Two entities with the same data but different identifiers are different entities. Identity determines entity equality, not state. Unlike a value object, an entity needs its own identifier. The book models it as a strongly typed value object generated via Uuid::v7().

Source: Eric Evans, Domain-Driven Design (2003), ch. 5

Value Object

A domain object without identity: two value objects with the same attributes are equal and interchangeable. They are immutable, so every “change” returns a new instance. Examples: Money, Email, Address, DateRange, ProductId. The book writes them with public readonly properties ($email->value). They take precedence over primitive types: they express domain intent, keep validation in one place, and prevent swapped arguments. Many concepts that developers store as a string or a number are in fact value objects.

Source: Eric Evans, Domain-Driven Design (2003), ch. 5

Aggregate

A cluster of domain objects (entities and value objects) treated as a single unit when data changes. It has exactly one aggregate root and enforces invariants inside its boundary: no operation may put it into an invalid state. Other aggregates refer to it only by the root’s identifier, never by a direct reference to inner entities. The aggregate boundary is also the transaction boundary. The default rule of thumb is that one transaction changes one aggregate; the Aggregate Design chapter covers the exceptions. Getting the aggregate size right is one of the hardest tasks in DDD. An aggregate that is too large loads dozens of inner entities on every operation, while one that is too small leaves invariants unprotected.

Source: Eric Evans, Domain-Driven Design (2003), ch. 6; Vaughn Vernon, Implementing Domain-Driven Design (2013), ch. 10

Aggregate Root

The single entity of an aggregate through which all outside access goes. It enforces all the aggregate’s invariants, which is why outside code changes inner objects only through its methods. Other aggregates keep only the root’s identifier, never a reference to inner entities. The root is also the only object that a repository stores and loads directly. In the book, it extends AggregateRoot, which records domain events with the record() method and releases them with releaseEvents().

Source: Eric Evans, Domain-Driven Design (2003), ch. 6

Repository

An abstraction for storing and loading aggregates that behaves like a collection. It hides persistence details from the domain: from the domain’s point of view, it is a collection of objects in memory. The repository interface belongs to the domain layer; the implementation (Doctrine, in-memory) belongs to infrastructure. There is one repository per aggregate type. It returns whole aggregates and offers no queries for inner entities. Reads for screens and reports go through other mechanisms (projections, read models).

Source: Eric Evans, Domain-Driven Design (2003), ch. 6

Factory

Encapsulates complex creation logic for an aggregate or a value object where a constructor is not enough. When the creation of an object is itself a domain act, a named constructor gives it a name (Order::place()). A factory can be a static method on the aggregate, a separate class, or a domain service. It separates responsibility for creating an object from using it. It is responsible for the new object satisfying its invariants, but it does not carry the logic of the object’s later behavior.

Source: Eric Evans, Domain-Driven Design (2003), ch. 6

Domain Service

A stateless service with a domain operation that belongs to no particular entity or value object. Examples: currency conversion, calculating a price with discounts from two different aggregates, and transferring money between accounts. It belongs to the domain layer and speaks the Ubiquitous Language. It is often confused with an application service; the difference lies in the content. An application service orchestrates a use case, while a domain service expresses a domain rule.

Source: Eric Evans, Domain-Driven Design (2003), ch. 5

Application Service

Orchestrates a use case: loads aggregates from repositories, calls domain methods, stores the result, and publishes domain events. It contains no domain logic; that belongs in entities, value objects, and domain services. It forms a thin layer between presentation and the domain. In CQRS, command handlers and query handlers correspond to it; in Symfony, classes with #[AsMessageHandler]. In hexagonal architecture, a driving adapter calls it through a driving port.

Source: Eric Evans, Domain-Driven Design (2003), ch. 4; Vaughn Vernon, Implementing Domain-Driven Design (2013), ch. 14

Domain Event

An immutable record of something significant that happened in the domain, named in the past tense and without an “Event” suffix: UserRegistered, OrderPlaced, PaymentFailed. The name is part of the Ubiquitous Language. Domain events connect aggregates inside one Bounded Context. Only an integration event, a separate public contract with primitive data, crosses the context boundary. How much data an event carries is a decision. Inside a context, identifiers are usually enough, and the recipient loads the rest itself. The aggregate records events in domain methods and named constructors, never in __construct. In Event Sourcing, domain events are the primary way of persisting state.

Source: Vaughn Vernon, Implementing Domain-Driven Design (2013), ch. 8; Eric Evans, Domain-Driven Design Reference (2015)

Integration Event

An event intended for other Bounded Contexts. Unlike a domain event, it is a public contract, so it changes only as fast as its recipients can tolerate. It carries only primitive values, so that it survives serialization, and its own eventId for deduplication at the recipient. In the book, it is a separate class in the application layer, for example OrderPlacedIntegrationEvent next to the domain event OrderPlaced. The handler builds it and stores it in the outbox in the same transaction as the aggregate change. Sending a domain event out directly means publishing the internal model.

Source: Cesar de la Torre, Domain events vs. Integration events in Domain-Driven Design and microservices architectures (Microsoft DevBlogs)

Specification

Encapsulates a business rule in a reusable, composable object: a predicate that determines whether a domain object meets a given criterion. Specifications combine with the logical operators AND, OR, and NOT, so a complex condition can be built from simpler ones. The rule thereby gets a name in the Ubiquitous Language (“the customer is premium”). Evans and Fowler formally described the pattern in the paper Specifications (1997), and Evans then included it in Domain-Driven Design (2003).

The original paper lists three uses. Validation checks that an object satisfies the rule (does the order qualify for free shipping?). Selection picks objects from a collection by a criterion, for example customers for a loyalty program. Building to order describes what a new object should look like without dealing with how to produce it. Specifications keep in one place the rules that would otherwise scatter across the domain, and they can be tested in isolation.

Source: Evans & Fowler, Specifications (1997); Eric Evans, Domain-Driven Design (2003), ch. 9

Invariant

A business rule that must always hold inside the aggregate boundary, however the aggregate changes. The aggregate root enforces it. Examples: “An order must have at least one item before it can be confirmed.” and “The total price of an order must not be negative.” Invariants define what a valid state is, and so they form the core of the domain model. An attempt to violate them ends with an exception, never by silently passing through.

Source: Eric Evans, Domain-Driven Design (2003), ch. 6

Domain Exception

A custom exception class that names the violated domain rule in the words of the Ubiquitous Language. Instead of generic exceptions (InvalidArgumentException, RuntimeException), the domain model throws exceptions named after the rule: InvalidOrderStateTransitionException, DuplicateEmailException, EmptyOrderException. They make code easier to read and errors easier to diagnose. The caller can also react to a specific failure separately, for instance with a different HTTP status. When an operation would violate an invariant, the aggregate rejects it with exactly such a domain exception. The exception to this is a format violation in a value object constructor (an invalid email, a negative amount): the book reports that as \InvalidArgumentException. A bare \DomainException is only an acknowledged shortcut in the book.

Source: Eric Evans, Domain-Driven Design (2003); Vaughn Vernon, Implementing Domain-Driven Design (2013)

03 Architectural patterns

What are architectural patterns in the context of DDD?

Architectural patterns determine how a system’s layers and components are organized, how they communicate, and where responsibilities lie. DDD prescribes no architecture. It combines with layered and hexagonal architecture as well as with vertical slices. The choice affects testability, maintainability, and whether the domain model stays free of infrastructure dependencies.

Layered Architecture

The classic four-layer architecture as described by Evans (2003): presentation layer → application layer → domain layer → infrastructure layer. Dependencies point in one direction; a layer may depend only on the layers below it. In Evans’s original model, the domain depends on infrastructure. Later variants (hexagonal and Onion architecture) invert this dependency through interfaces, so the domain depends on no technical layer. For DDD, layered architecture is a natural starting point. It sorts code by technical role rather than by business function, however, so the directories do not show what the system does.

Source: Eric Evans, Domain-Driven Design (2003), ch. 4

Hexagonal Architecture (Ports and Adapters)

An architecture proposed by Alistair Cockburn. The application core (the domain and the application layer) communicates with the outside world only through ports (interfaces) and adapters (implementations). Driving adapters (an HTTP controller, a console command) call the application; driven adapters (database, messaging, email) are called by the application. The main benefit: the domain model is isolated from infrastructure and can be tested without a database, an HTTP framework, or external systems. The dependency inversion principle (DIP) is applied systematically here.

Source: Alistair Cockburn, Hexagonal Architecture (2005), alistair.cockburn.us; Vaughn Vernon, Implementing Domain-Driven Design (2013), ch. 4

Port

In hexagonal architecture, an interface through which the application communicates with the outside world. Driving ports define how outside actors call the application (for example, MessageBusInterface or a custom use case interface). Driven ports describe what the application needs from infrastructure (for example, UserRepository, EmailSender). Ports belong to the application core, that is, the domain or application layer, never to infrastructure.

Source: Alistair Cockburn, Hexagonal Architecture (2005)

Adapter

In hexagonal architecture, a concrete implementation of a port. An adapter translates between the protocol of the outside world and the interface of the application core. Examples: DoctrineUserRepository implements the UserRepository port; SymfonyMailerEmailSender implements the EmailSender port; an HTTP controller is a driving adapter that calls the application through a driving port (for example, MessageBusInterface). Adapters belong to the infrastructure layer and can be replaced without changing the domain model.

Source: Alistair Cockburn, Hexagonal Architecture (2005)

Vertical Slice Architecture

Organizes code by feature and use case, not by technical layer. Each slice (for example, Registration) is a vertical cut through the whole stack: the controller, command, handler, domain logic, and repository sit together. Features depend on each other less, so changing one does not touch the others. Classic horizontal layering, by contrast, keeps all controllers in one place and all repositories in another. A slice corresponds to one use case, and slices are further grouped by Bounded Context.

Source: Jimmy Bogard, Vertical Slice Architecture (2018), jimmybogard.com

CQRS

Command Query Responsibility Segregation: an architectural pattern that separates reads (queries) from writes (commands). Each side has its own model. The write model rests on rich aggregates and enforces invariants; the read model returns optimized DTOs or projections. A separate store is optional and not part of the definition. Greg Young described the pattern. Its roots go back to Bertrand Meyer’s CQS, but Young himself calls the phrase “CQRS is an extension of CQS” inaccurate and treats CQRS as a pattern in its own right. In DDD, it complements a domain model that is too rich to be displayed directly in the UI. Each side can then be optimized separately.

Source: Greg Young, CQRS Documents (2010); Vaughn Vernon, Implementing Domain-Driven Design (2013), ch. 4

CQS

Command-Query Separation, Bertrand Meyer’s principle: a method is either a command (changes state and returns void) or a query (returns data without side effects), never both. Code that violates CQS is harder to test and behaves unpredictably when called repeatedly. CQRS builds on this principle but does not apply it mechanically: it separates whole models, not individual methods. CQS is not a prerequisite, though; CQRS can be introduced without strictly following it at the method level.

Source: Bertrand Meyer, Object-Oriented Software Construction, 2nd edition (1997), ch. 23; the principle first appeared in the 1st edition (1988)

Event Sourcing

A persistence pattern that stores an append-only sequence of domain events instead of the current state. The aggregate’s state comes from replaying the event stream from the beginning or from the latest snapshot. The stream also serves as an audit log: every change stays recorded. State can be reconstructed for any point in the past. Event Sourcing and CQRS complement each other: the write model generates events, and projectors build read models from them.

Source: Greg Young, CQRS Documents (2010); Vaughn Vernon, Implementing Domain-Driven Design (2013), ch. 4

Event Store

The append-only store of domain events in Event Sourcing. It saves events into each aggregate’s stream with guaranteed ordering. Records are never changed or deleted, which is the fundamental invariant of Event Sourcing. An event store usually offers appending new events to a stream with a version check (optimistic locking), reading a stream from any position, and subscribing to new events. Examples: EventStoreDB, Marten (PostgreSQL), or a custom implementation on top of a relational database.

Source: Greg Young, CQRS Documents (2010)

Projection

A read model built from an event stream. A projector listens to domain events and updates a denormalized structure optimized for reading (a table, a document, a cache). A projection can be thrown away at any time and rebuilt by replaying events from the event store, because it is derived data, not the source of truth. One set of events can feed several projections with different structures for different screens.

Source: Greg Young, CQRS Documents (2010); Vaughn Vernon, Implementing Domain-Driven Design (2013), ch. 4

Snapshot

In Event Sourcing, a periodically saved state of an aggregate that shortens stream replay. Instead of all events from the beginning (there can be thousands), the latest snapshot is loaded and only the events after it are replayed. It is a performance optimization and does not affect the correctness of the model. It is introduced only once replay slows down measurably. Snapshots are optional and are not the source of truth.

Source: Greg Young, CQRS Documents (2010)

Saga / Process Manager

A saga breaks a long-running business process spanning several aggregates or Bounded Contexts into a series of local transactions. When a step fails permanently, compensating transactions undo the completed steps in reverse order and bring the system to a consistent state. It is the semantic counterpart of a rollback in a distributed environment. Example: completing an order with payment, a stock reservation, and a notification. The term “saga” comes from database research (Garcia-Molina and Salem, 1987). A Process Manager is not a synonym but an orchestrating component with persistent state that drives the saga. Enterprise Integration Patterns (Hohpe & Woolf, 2003) describes it.

A saga can be coordinated in two ways. In choreography, there is no central coordinator: each participant reacts to the events of the others and publishes its own. In orchestration, a Process Manager drives the flow; it receives events, decides on the next step, and issues commands. The choice between them depends not on the number of steps but on the shape of the process. Choreography handles a linear sequence known in advance, while a Process Manager pays off where the next step is decided only at runtime or the steps do not run one after another. Terminology varies between authors; the Sagas and Process Managers chapter discusses which convention the book follows.

Source: Vaughn Vernon, Implementing Domain-Driven Design (2013), ch. 4; Hohpe & Woolf, Enterprise Integration Patterns (2003); Garcia-Molina & Salem, Sagas (1987)

04 Integration patterns and communication

What are integration patterns?

The terms in this section describe how parts of a system communicate, how consistency is maintained in a distributed environment, and how conflicts under concurrent access are prevented. Two anti-patterns belong here as well: common mistakes in domain modeling. Without these terms, it is hard to design a system that withstands concurrency and component outages.

Eventual Consistency

A consistency model in which data replicas converge on the same value once no further changes arrive. That need not happen immediately. In DDD with CQRS, the read model can lag behind the write model for a while after a command is processed and an event published. Such a delay tends to be acceptable, but the business must know about it and accept that data freshness has limits. Between aggregates and in distributed systems (the CAP theorem), it is a necessary trade-off.

Source: Werner Vogels, Eventually Consistent (ACM Queue, 2008); Vaughn Vernon, Implementing Domain-Driven Design (2013), ch. 4

Optimistic Locking

Lock-free concurrency control based on a version number. On write, the system checks whether the version in the database matches the version loaded at read time. If another process has changed the aggregate in the meantime, a conflict arises and the operation fails. The client then loads the new state and retries the operation. In Event Sourcing, the version derives from the position in the stream. It fits where conflicts are rare. Watch out for Doctrine: #[ORM\Version] on the root is incremented only when the root’s own properties change, not when a child changes.

Source: Martin Fowler, Patterns of Enterprise Application Architecture (2002)

Pessimistic Locking

Concurrency control that actually locks the resource in the database (typically with SELECT … FOR UPDATE or LOCK TABLES) for the whole transaction. Concurrent operations on the same record block and wait in a queue. It fits frequent conflicts, short transactions, and cases where retrying an operation costs more than waiting. The price is lower throughput and a risk of deadlock, which a consistent locking order and holding locks briefly both reduce. Event Sourcing usually does without it, because the events in a stream are ordered and a version check is enough.

Source: Martin Fowler, Patterns of Enterprise Application Architecture (2002); Bernstein & Newcomer, Principles of Transaction Processing (2009), ch. 6

Read Model

A data structure optimized for reading and separated from the write model (the domain model). The term comes from CQRS. The write side holds invariants in aggregates and works through repositories; the read side feeds screens and reports with precomputed, denormalized data. A read model can be kept up to date synchronously in the same transaction as the write, or asynchronously with a short delay. In both cases, it is usually populated by projections that listen to domain events. It often combines data from several aggregates whose joint query would break their isolation on the write side. Each use case can have its own read model, so one aggregate contributes to several of them.

Source: Greg Young, CQRS Documents (2010); Vaughn Vernon, Implementing Domain-Driven Design (2013), ch. 4 and 8

Compensation

Also called a compensating action: an operation that semantically undoes the effect of an earlier saga step without an ACID rollback. Example: RefundCustomer compensates ChargeCustomer, and ReleaseStock compensates ReserveStock. A compensating step must be idempotent (calling it repeatedly has the same effect as calling it once) and tolerant of the compensated step being absent (for example, when the process failed before the reservation). Compensations run in the reverse order of the completed steps. Commutative operations are a different tool: Richardson lists them as a countermeasure against isolation anomalies between concurrent sagas. Some effects cannot be undone (a sent email, physically dispatched goods). Compensation then looks different: an apology email, a refund, a credit note.

Source: Hector Garcia-Molina & Kenneth Salem, Sagas (ACM SIGMOD, 1987); Chris Richardson, Microservices Patterns (2018), ch. 4

Anemic Domain Model

An anti-pattern in which domain classes carry only data (getters and setters) and the domain logic lives in service classes. It breaks encapsulation and runs against the rich domain model that DDD stands on. The domain objects are reduced to data structures, and the logic scatters so widely that nobody can find it. Martin Fowler named it as an anti-pattern in 2003. It often appears even in projects that claim to follow DDD.

Source: Martin Fowler, AnemicDomainModel (2003); Eric Evans, Domain-Driven Design (2003), ch. 5

Primitive Obsession

An anti-pattern in which domain concepts are carried by primitive types (string, int, float) instead of value objects. Validation scatters, because everyone who accepts a string holding an email has to check it themselves. Meaning gets lost, and arguments can be swapped: a function with the parameters int $orderId and int $userId accepts the values in the wrong order without a type error. The fix is the value objects OrderId, UserId, Email, and Money, which carry both validation and meaning.

Source: Martin Fowler et al., Refactoring (1999), ch. 3 (code smell); Eric Evans, Domain-Driven Design (2003), ch. 5

Correlation ID

A unique identifier created once for an HTTP request or for the message that started a process. Derived commands and events inherit it and do not generate correlation IDs of their own. It enables distributed tracing, that is, linking all the operations triggered by one user action. In a system with asynchronous communication or with microservices, diagnostics cannot do without it. Between services, it travels in an HTTP header (for example, X-Correlation-ID); in Messenger, in a stamp on the envelope. It differs from a saga’s business correlation key (typically orderId), which tells the saga which instance a message belongs to.

Source: Vaughn Vernon, Implementing Domain-Driven Design (2013), ch. 8; Gregor Hohpe & Bobby Woolf, Enterprise Integration Patterns (2003)

Causation ID

The counterpart of the correlation ID. It identifies the specific event or command that directly caused the current event to be issued. The correlation ID links the whole chain back to the original cause; the causation ID points only to the immediate predecessor. Together, they let you reconstruct the whole chain: which command caused what, which events came out of it, and which further commands those events triggered.

Source: Vaughn Vernon, Implementing Domain-Driven Design (2013), ch. 8

05 DDD testing terms

Testing in the context of DDD

A well-separated domain model is easy to test. Domain logic does not depend on infrastructure, so unit tests run fast and deterministically without a database, HTTP, or external systems. The terms in this section cover tools for verifying domain rules, the architecture, and system behavior during migration from legacy code.

Test Double

A general term for any object that replaces a real dependency in a test. The name comes from film, where a “stunt double” stands in for an actor in dangerous scenes. Gerard Meszaros (xUnit Test Patterns, 2007) distinguishes five types: Dummy, Stub, Fake, Mock, and Spy. Each serves a different purpose, and the wrong choice makes tests brittle.

Source: Gerard Meszaros, xUnit Test Patterns (2007), ch. 11

Stub

A test double that returns preset answers without any logic. It does not verify calls. It only supplies a value to the code under test where the real dependency would reach into a database, the network, or another external resource. Example: StubExchangeRateProvider always returns an exchange rate of CZK 25 per EUR. The test does not care whether the stub was called, only what it returned.

Source: Gerard Meszaros, xUnit Test Patterns (2007), ch. 11; Martin Fowler, Mocks Aren't Stubs (martinfowler.com, 2004)

Mock

A test double that verifies calls: it expects specific methods to have been called with specific arguments. When a call is missing or happens differently, the test fails. The risk is overspecification, where the test checks implementation details instead of behavior and breaks with every refactoring. In DDD, a mock fits calls to external ports, not calls inside an aggregate.

Source: Gerard Meszaros, xUnit Test Patterns (2007), ch. 11; Martin Fowler, Mocks Aren't Stubs (2004)

Fake

A working but simplified implementation of an interface. Example: InMemoryUserRepository stores data in an in-memory array and needs no database. For repositories, it is the default test double in DDD. Unlike a mock, it does not tie tests to implementation details. Unlike a stub, it actually works, so it uncovers bugs in logic that depends on query results. It takes more work to write, but the tests gain value.

Source: Gerard Meszaros, xUnit Test Patterns (2007), ch. 11

Characterization Test

A test that captures the current behavior of legacy code before refactoring. It describes what the code does, not what it should do. During migration from CRUD to DDD, it serves as a safety net: it makes sure the refactoring does not change the system’s observable behavior. Michael Feathers introduced the term in Working Effectively with Legacy Code (2004). Characterization tests are temporary. After the migration, tests that describe the intended behavior gradually replace them.

Source: Michael Feathers, Working Effectively with Legacy Code (2004), ch. 13

Architecture Test

An automated test that guards the dependency rules between layers or modules. For example: “The domain layer must not depend on infrastructure” or “No class in the Domain\ namespace may import a class from Infrastructure\.” Architecture tests are executable documentation of architectural decisions. They prevent architectural erosion, the gradual breaking of rules that sets in by itself without automated checks. Tools for PHP: Deptrac and PHPArkitect.

Source: Deptrac (github.com/deptrac/deptrac), PHPArkitect (github.com/phparkitect/arkitect); broader context: Mark Richards & Neal Ford, Fundamentals of Software Architecture (2020), ch. 6, “Measuring and Governing Architecture Characteristics” (fitness functions).

06 Overloaded terms – false friends

Why the confusion arises

DDD terms overlap with concepts from Symfony, its security component, Doctrine, and the Spring and Java world. The same word therefore means different things in different contexts, and an ordinary code review often misses the mismatch. The entries below untangle the mix-ups that keep recurring in DDD projects regardless of team or framework.

ACL

In DDD: Anti-Corruption Layer, the translation layer between a Bounded Context and a foreign model. Outside DDD: Access Control List, an authorization list (who may do what). In DDD literature, “ACL” always means the former. Details.

Repository

In DDD: a domain abstraction, an interface in App\<BC>\Domain with get() and save() methods that treats the aggregate as if it lived in memory. In Symfony and Doctrine: Doctrine\ORM\EntityRepository, a class with findBy and findAll. A DDD repository is always an interface; a Doctrine EntityRepository is always an implementation in App\<BC>\Infrastructure.

Service

In DDD: a domain service (a domain rule without an owner), an application service (use case coordination), or an infrastructure service (a port adapter). In Symfony: any class in the DI container. A name like FooService without the type therefore says nothing.

Event

In DDD: a domain event (OrderPlaced, a fact that happened in the domain). In Symfony: an object passed to the EventDispatcher, typically a framework or kernel event (KernelEvents::REQUEST). A domain event therefore does not extend Symfony\Contracts\EventDispatcher\Event; otherwise the domain would depend on the framework.

Entity

In DDD: an object with identity (Customer, Order), either an aggregate root or an inner part of an aggregate. In Doctrine: a class with the #[ORM\Entity] attribute mapped to a database row. A DDD entity may or may not also be a Doctrine entity.

Domain

In DDD: the business area that the software models (Ordering, Billing, Catalog). In Twig and translations: a translation domain (messages, validators). Elsewhere in PHP, the word appears rarely, so the risk of confusion lies mainly in translations.

Controller

In Symfony: a class that handles an HTTP request. In DDD: a driving adapter that belongs in App\<BC>\Infrastructure\Http\, not in Application, let alone in Domain.

Handler

In Symfony Messenger: a class with #[AsMessageHandler] that the message bus calls for a given message. It orchestrates the use case and delegates domain logic to the aggregate. In DDD: an application service if it processes a command, or a domain event handler if it reacts to an event. Both belong in the application layer.

Aggregate

In DDD: a cluster of objects that change atomically. In SQL and reporting: an aggregate function (SUM, COUNT). The meanings do not overlap, but the shared word confuses beginners.

07 Symfony ↔ DDD mapping (extended table)

A short version of the table is in the Cheat Sheet. This extended version adds links to chapters and anti-patterns.

Symfony construct DDD term Location in the project Details / anti-pattern
Controller (HTTP) Driving adapter (infrastructure) App\<BC>\Infrastructure\Http\ Hexagonal architecture – adapter · Anti-pattern: domain logic in the controller
#[AsMessageHandler] handler Application service (use case) App\<BC>\Application\Handler\ CQRS · delegates domain logic to the aggregate
EntityRepository (Doctrine) Repository – implementation App\<BC>\Infrastructure\Doctrine\Doctrine<X>Repository.php The interface lives in the domain
Voter Use case authorization App\<BC>\Infrastructure\Security\ Authorization – Voter
Form Input mapping (DTO) App\<BC>\Infrastructure\Http\Form\ Form getData() → command DTO, not the aggregate directly
Twig template View over a read model templates/<bc>/ Displays the read model, not the write model
Messenger transport (sync) Command and event bus inside a single process monolith –
Messenger transport (async, AMQP) Asynchronous processing; only integration events cross the context boundary between Bounded Contexts or services Outbox Pattern · DDD and Microservices
Console Command Driving adapter (alternative to HTTP) App\<BC>\Infrastructure\Cli\ Calls the same application services as the HTTP controller
Doctrine Migration Database schema evolution migrations/ No DDD equivalent, pure infrastructure
EventSubscriber (Doctrine postPersist) Infrastructure (not a domain event handler) App\<BC>\Infrastructure\Doctrine\EventListener\ Anti-pattern: domain rules in a Doctrine listener

★ Primary literature

The definitions in this glossary draw on the following primary sources:

  • Evans, Eric. Domain-Driven Design: Tackling Complexity in the Heart of Software. Addison-Wesley, 2003. ISBN 978-0-321-12521-7
  • Vernon, Vaughn. Implementing Domain-Driven Design. Addison-Wesley, 2013. ISBN 978-0-321-83457-7
  • Vernon, Vaughn. Domain-Driven Design Distilled. Addison-Wesley, 2016. ISBN 978-0-13-443442-1
  • Fowler, Martin. Patterns of Enterprise Application Architecture. Addison-Wesley, 2002. ISBN 978-0-321-12742-6
  • Young, Greg. CQRS Documents. 2010. Available at: cqrs.files.wordpress.com