Reference · DDD Cheat Sheet

DDD Cheat Sheet

One-page navigation through the whole book. If you remember only a term, this page links you to the details. If you are unsure which pattern to use, walk through the decision tree. The page has no examples; those live in the linked chapters.

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

The cheat sheet complements the glossary and the reference hub. A single page links to the part of the book you need right now, so you do not have to remember how the content is structured.

cs.01 Decision tree – what to use and when

The table maps a typical symptom or requirement to a pattern and links to the chapter with the details. It is not exhaustive. It covers the 14 most common situations where DDD answers with a specific pattern.

Situation Pattern Details
A complex domain at the core of the business Full DDD – strategic and tactical What Is Domain-Driven Design · Subdomains: Core, Supporting, Generic
Two or more Bounded Contexts that communicate with each other Context Map Bounded Context and Context Mapping
A legacy system you need to take data from Anti-Corruption Layer (ACL) Context Mapping – ACL
A long-running process with compensation Saga / Process Manager Sagas and Process Managers
State is a sequence of events Event Sourcing Event Sourcing
Separate reads and writes CQRS CQRS
Writing state and publishing an event in one transaction Outbox Pattern Outbox Pattern
A composable domain rule Specification Specification Pattern
Logic that does not belong in an entity Domain Service Domain Services
Complex creation of an aggregate Factory Factories
A workshop for discovering the domain Event Storming Event Storming and Domain Storytelling
Reorganizing teams around Bounded Contexts Team Topologies Conway's Law and Team Topologies
Authorization at the use case level Symfony Voter Authorization – Voter
Gradual migration from CRUD Strangler Fig Pattern Migrating from CRUD to DDD

cs.02 Symfony ↔ DDD mapping (quick table)

A short version of the table for quick orientation. The full version, with links to anti-patterns and chapters, is in the Symfony ↔ DDD mapping (extended table) section of the glossary.

Symfony construct DDD concept Note
Controller Driving adapter (HTTP) Domain logic does not belong here
#[AsMessageHandler] handler Application service (use case) One command = one handler; it delegates domain logic to the aggregate
EventSubscriber (Doctrine/Kernel) Infrastructure Not a domain event handler
Domain event handler Application service Reacts to a domain event and leaves the decision to the aggregate or a domain service
Entity (with ORM) Aggregate root or entity Attribute mapping is the default; a separate persistence model is described in Persisted Object
Repository (Doctrine) Repository Interface in the domain, implementation in the infrastructure
Voter Use case authorization The aggregate guards domain invariants, not the Voter
Service (autowire) Application, domain, or infrastructure service The kind of service must be clear from the code
Form Input mapping Fills a command DTO and does not call aggregate methods
Messenger transport (sync) In-process command and event bus Monolith
Messenger transport (async) Asynchronous processing Across a context boundary, only integration events through the Outbox (AMQP, Kafka)

cs.03 False friends – word traps

The same word means something different in DDD than in Symfony, PHP, or SQL. The table summarizes the 7 most common mix-ups. The complete overview, with 9 entries and a more detailed discussion, is in the Overloaded terms – false friends section of the glossary.

Term In DDD In Symfony / in general How to tell them apart
ACL Anti-Corruption Layer Access Control List In DDD literature, always the former
Repository A domain collection of aggregates The Doctrine EntityRepository class A DDD repository is an interface; the Doctrine class is its implementation
Service A stateless object (domain, application, or infrastructure service) A Symfony service (anything in the DI container) The kind of service belongs in the name or namespace
Event A domain event (OrderPlaced) A Symfony EventDispatcher event A Symfony event ≠ a domain event
Entity An object with identity in the domain A Doctrine entity (mapped through the ORM) A DDD entity can also live inside an aggregate
Aggregate A consistent cluster of objects An SQL aggregate function (SUM, COUNT) The meanings do not overlap, but they confuse beginners
Domain An area of business A translation domain in Twig (messages) Usually the DDD meaning

cs.04 Reading paths – what to read by role

The book has 25 chapters, and nobody has to read all of them. Below are four paths for typical roles and situations. Each one respects the dependencies between chapters and leads from the basics to advanced topics. Reading times come from the estimates in the book's table of contents.

Junior PHP developer, first contact with DDD

If you have never worked with DDD and want to understand what it is about before you start refactoring production code:

  1. 01 – What Is Domain-Driven Design
  2. 06 – DDD Building Blocks
  3. 07 – Aggregate Design
  4. 10 – Implementation in Symfony 8
  5. 17 – Testing DDD

Reading time: about 155 minutes. Goal: understand the vocabulary and know what “aggregate” or “Bounded Context” means in a code review.

Architect on a new project

You are building a greenfield project and want to lay out the strategic design from the start: Bounded Contexts, team topology, and integration patterns:

  1. 02 – Subdomains: Core, Supporting, Generic
  2. 03 – Bounded Context and Context Mapping
  3. 04 – Event Storming and Domain Storytelling
  4. 05 – Conway's Law and Team Topologies
  5. 09 – Architectural Styles
  6. 19 – DDD and Microservices

Reading time: about 251 minutes. Goal: a complete picture for an architecture review and a roadmap.

Migrating an existing Symfony project

You have a production CRUD application in Symfony and want to move it to DDD gradually, without rewriting it all at once:

  1. 01 – What Is Domain-Driven Design
  2. 04 – Event Storming and Domain Storytelling (discovering the implicit domain)
  3. 06 – DDD Building Blocks
  4. 07 – Aggregate Design
  5. 18 – Migrating from CRUD to DDD (including the refactoring cookbook)
  6. 21 – Anti-Patterns and Common Mistakes

Reading time: about 182 minutes, then weeks of refactoring. Goal: a concrete plan for the first five pull requests of the migration.

Tech lead before a release

Before a production release, you want to be sure the infrastructure patterns (CQRS, Event Sourcing, sagas, and Outbox) are built correctly and tested:

  1. 12 – CQRS
  2. 13 – Event Sourcing
  3. 14 – Sagas and Process Managers
  4. 15 – Outbox Pattern
  5. 17 – Testing DDD

Reading time: about 214 minutes. Goal: a checklist for the pre-release review.

cs.05 External resources worth reading

Five books and three talks for anyone who wants to use DDD seriously. The complete bibliography (articles, repositories, courses, communities, and official documentation) is on a separate page, Resources.

Five books

Author Title Why read it
Eric Evans (2003) Domain-Driven Design: Tackling Complexity in the Heart of Software The founding book. The vocabulary of the whole field.
Vaughn Vernon (2013) Implementing Domain-Driven Design A practical follow-up to Evans: implementation patterns and CQRS.
Vaughn Vernon (2016) Domain-Driven Design Distilled A concise digest for readers who hesitate to invest time in the full Implementing DDD.
Vlad Khononov (2021) Learning Domain-Driven Design A view from 18 years after Evans. It gives more room to strategic design and to deciding where DDD pays off.
Greg Young (2010) CQRS Documents (free PDF) The original texts by the author who described CQRS. Dense and precise.

Three talks

  1. Eric Evans – Tackling Complexity in the Heart of Software (DDD Europe keynote, ~55 min). A shorter account of the ideas from the book of the same name. If you have no time for the book, at least watch the talk.
  2. Greg Young – CQRS and Event Sourcing (Code on the Beach 2014, ~65 min). Using practical cases, Young shows when it makes sense to separate commands from queries and when to go all the way to event-based storage.
  3. Jimmy Bogard – Vertical Slice Architecture (NDC, ~60 min). The case for vertical slices instead of horizontal layers. It concerns how code is organized inside a Bounded Context.

Concrete implementation examples are in Practical Examples and in the chapter Implementation in Symfony 8. A more detailed vocabulary is in the Glossary.