Domain-Driven Design Interview Questions

2,511 multiple-choice tech interview questions on Domain-Driven Design: Ubiquitous language, knowledge crunching and domain discovery, making implicit concepts explicit, refactoring toward deeper insight, supple design (including intention-revealing interfaces and closure of operations), and the model exploration whirlpool, subdomains and bounded contexts (core, supporting, and generic subdomains, distillation, highlighted and segregated cores, linguistic boundaries, and bubble contexts), context maps and integration patterns (as-is and to-be maps, partnership, customer-supplier, shared kernel, conformist, anti-corruption layer, open host service, published language, and separate ways), entities and value objects (identity and continuity, natural and surrogate keys, early identity, immutability and conceptual wholes, always-valid construction, and line-item snapshots), aggregates and invariants (boundaries and clustering, roots and encapsulated collections, transactional consistency, one-aggregate transactions, and identity references), domain events and consistency between aggregates (uncommitted events and after-commit dispatch, eventual and immediate consistency, process managers and compensating actions, reservations, and thin versus event-carried events), repositories, factories and domain services (next identity, intention-revealing queries, repository per aggregate, standalone factories and creation methods, in-memory repositories, and explicit save), collaborative modeling (chaotic exploration, unlimited modeling space, fictitious events, software design event storming, event modeling, impact mapping, and domain message flow), and applying DDD (logical CQRS, current-state persistence, read-model staleness, strategic-only DDD, Implementing Domain-Driven Design, Domain Modeling Made Functional, and Balancing Coupling in Software Design). Written for technical phone screens and interview prep, organized by subtopic, with a short explanation for every answer. Learn the 151 key terms with the flashcards first, then test yourself.

Take the practice test · Flashcards · All study tools

What it covers

  1. 8.1 Ubiquitous language and domain discovery
  2. 8.2 Subdomains and bounded contexts
  3. 8.3 Context mapping and integration patterns
  4. 8.4 Entities and value objects
  5. 8.5 Aggregates and invariants
  6. 8.6 Domain events and consistency between aggregates
  7. 8.7 Repositories, factories and domain services
  8. 8.8 Collaborative modeling: event storming and beyond
  9. 8.9 Applying DDD: CQRS, event sourcing and when to use it

Key terms

8.1 Ubiquitous language and domain discovery

Domain expert
Person with deep knowledge of the business area
Knowledge crunching
Collaboratively distilling a useful domain model
Domain model
Purposeful simplified representation of the domain
Refactoring toward deeper insight
Reshaping the model as understanding grows
Domain storytelling
Recording how work happens as pictographic stories
Supple design
Design that's easy to change and understand
Intention-revealing interface
Names that state what code does and why
Side-effect-free function
Operation that returns a result without changing state
Conceptual contours
Splitting design along the domain's natural seams
Hands-on modeler
Person who shapes the model and writes its code
Blue book
Eric Evans' 2003 book "Domain-Driven Design"
Closure of operations
An operation whose result is the same kind of thing as its inputs, so those operations can be combined without leaving the model
Declarative design
Arranging a model so a caller can say what should hold or happen in domain words, rather than spelling out a mechanical procedure
Standalone class
A type that can be understood and used with little context from the rest of the model, because its meaning is self-contained
Model exploration whirlpool
An iterative loop of probing the domain, trying a model, and using what you learned to probe again, instead of a single linear analysis phase
Deep model
A model that captures hidden rules and distinctions in the domain, not just the obvious nouns, so the work becomes easier to express
Making implicit concepts explicit
Turning a hidden rule, policy, or idea into a named model element that can be discussed, tested, and reused
Modeling breakthrough
A better way of seeing the work that lets a team rename, split, or drop concepts and usually simplifies the model
Model-driven design
Building the software so the code is a direct expression of the domain model, and changing one means changing the other

8.2 Subdomains and bounded contexts

Subdomain
Distinct area of the business problem space
Supporting subdomain
Necessary, non-differentiating subdomain built in-house
Generic subdomain
Commodity capability, usually bought or reused
Bubble context
Small new model inside a legacy system, protected by translation
Domain vision statement
Short statement of the core domain's value
Distillation
Separating the core domain from supporting parts
Segregated core
Core concepts refactored into their own module
Core domain chart
Plot of subdomains by differentiation and complexity
Highlighted core
Making the core domain obvious in the code, for example by packaging or marking it, so people can find and protect it even before a full extract
Linguistic boundary
A place where words change meaning or a new vocabulary appears, often a signal to draw a different model and a different bounded context
Cohesive mechanisms
Generic or reusable mechanisms packaged separately so their detail does not clutter the core domain language
Abstract core
A small set of the most essential core-domain concepts, factored so the rest of the core can be understood in terms of them
Problem space
The business problem as it exists independently of a particular software design; in DDD this is where subdomains live
Solution space
The software design that addresses the problem, including bounded contexts and how those models are bounded and connected

8.3 Context mapping and integration patterns

Ubiquitous language
Shared vocabulary of developers and domain experts, reflected in code
Bounded context
Boundary within which one model and language apply
Anti-corruption layer
Translation layer protecting a model from external concepts
Core domain
The part of the business that differentiates it
Context map
Map of bounded contexts and their relationships
Customer-supplier
Upstream plans with the downstream customer's needs in mind
Partnership
Two teams coordinating closely and succeeding or failing together
Conformist
Downstream adopts the upstream model as is
Open host service
Upstream offers a well-defined protocol for any consumer
Published language
Documented shared format for exchanging information
Separate ways
Contexts that don't integrate at all
Upstream context
Context whose model and changes affect others
Downstream context
Context that depends on another's model
Integration event
Event published across context boundaries as a contract
Bounded context canvas
One-page template describing a context
As-is context map
A map of the relationships and integrations that actually exist today, drawn before a wished-for design so real couplings and power are visible
To-be context map
A planned map of how context relationships should look after a change, useful only after an honest as-is map is in place
Semantic coupling
Coupling that comes from sharing meaning, categories, or model assumptions, not just from a technical connection between systems
Model corruption
Distortion of a context's own model when an upstream or shared model leaks in without translation, so people start thinking in a foreign language
Fat anti-corruption layer
A translation layer that has grown into a large second domain model of its own, instead of staying a modest boundary that protects one context
Independent evolution
The ability of a context to change its internal model on its own timeline because integrations are explicit, translated, and versioned rather than hidden

8.4 Entities and value objects

Entity
Object with a lasting identity
Value object
Immutable object defined by its values
Repository
Collection-like access to aggregates, hiding persistence
Identity
Stable ID that tells an entity apart over time
Surrogate key
ID with no business meaning, like a GUID
Natural key
Business attribute used as an ID, like an email
Owned type
Value object stored in its parent's table by an ORM
Micro-type
Small type wrapping one primitive with its own rules
Entity lifecycle
States an entity moves through under domain rules
Always-valid object
Object that validates on creation so invalid instances can't exist
Conceptual whole
Attributes that only make sense together, like amount and currency
Continuity of identity
The idea that an entity remains the same thing over time because of its identity, even as its attributes change
Identity equality
Two entity instances are considered the same when they share a stable identity, not when all of their attributes match
Early identity
An identifier assigned in the domain or application before the entity is persisted, so it can be referenced immediately
Transient entity
An entity that already has a domain identity but has not yet been persisted
Business key
A unique business attribute or combination of attributes used to find an entity, kept distinct from the stable identity that references should use
Line-item snapshot
A value object that captures a product's price, description, or other facts as they were at the moment of an order, rather than relying only on a live catalog entity

8.5 Aggregates and invariants

Aggregate
Cluster of objects changed as a unit through its root
Domain event
Past-tense record of something meaningful in the domain
Aggregate root
Entity guarding an aggregate's invariants; the only external entry point
Consistency boundary
Scope where rules are enforced immediately
True invariant
Rule that must hold at all times within a transaction
Optimistic concurrency
Version check that rejects conflicting saves
Reference by identity
Linking aggregates by ID instead of object references
Tactical design
Code-level DDD building blocks
Strategic design
Big-picture DDD: subdomains, contexts and their relationships
Aggregate design canvas
Template for an aggregate's commands, events and invariants
Local identity
An identifier that is unique only inside its aggregate, used for child entities that outsiders should not reference directly
Global identity
An identifier that is unique and referenceable from outside the aggregate, typically belonging to the aggregate root
Transactional consistency
The requirement that a rule hold immediately when the transaction for a consistency boundary commits, without waiting for later reconciliation
One-aggregate transaction
The usual DDD practice of modifying only one aggregate in a transaction and handling other effects later
Encapsulated collection
A collection of child entities or values that is not exposed for direct mutation, so all changes go through the aggregate root
Child entity
An entity that lives only inside an aggregate, is reached through the root, and is not a consistency boundary on its own

8.6 Domain events and consistency between aggregates

Eventual consistency
Related aggregates catch up later through events
Process manager
Component reacting to events and sending commands for a multi-step process
Policy
"Whenever X happens, do Y" rule linking events to commands
Compensating action
Step that undoes or offsets an earlier step
Reservation pattern
Hold a resource temporarily, then confirm or release
Event-carried state transfer
Events include enough data that consumers needn't call back
Thin event
Event carrying only IDs, with details fetched as needed
Given-when-then
Test style: prior events or state, a command, expected outcome
Uncommitted events
The pending list of domain events an aggregate records during a method, to be dispatched only after the transaction succeeds and then cleared
After-commit dispatch
The practice of publishing recorded domain events only after the aggregate's transaction has committed, so handlers do not act on work that is rolled back
In-process handler
A reaction to a domain event that runs in the same application process, typically after commit, without requiring a cross-process message bus
Immediate consistency
A requirement that a rule hold as soon as a transaction commits, with no business-acceptable delay, usually enforced inside one aggregate
Reservation expiry
The end of a time-bounded hold on a scarce resource, after which the claim is released if it has not been confirmed
Subscriber autonomy
The idea that consumers decide whether and how to react to a domain event, rather than the producing aggregate naming or calling its subscribers
Process manager state
The durable memory a process manager keeps of which facts it has seen, which steps already ran, and what it is waiting for

8.7 Repositories, factories and domain services

Factory
Encapsulated creation of complex objects or aggregates
Domain service
Stateless operation with domain rules spanning entities
Application service
Orchestrates a use case over the domain
Infrastructure service
Technical service behind a domain-defined interface
Persistence ignorance
Domain objects don't know how they're stored
Reconstitution
Rebuilding an aggregate from storage without rerunning creation rules
Module
Named grouping of related model concepts
Collection-oriented repository
Repository that mimics an in-memory set
Persistence-oriented repository
Repository where callers save aggregates explicitly
Generic repository
One CRUD interface for all types
Next identity
A repository or generator operation that issues a unique aggregate id before the first save, so the new cluster can exist in memory with a stable identity
Intention-revealing query
A repository lookup named in domain language, such as GetActiveSubscriptions, instead of a technical column filter
Repository per aggregate
The rule that only aggregate roots have repositories, so inner entities are loaded and saved through their root
Standalone factory
A factory class separate from the aggregate, used when creation needs collaborators or spans several objects
In-memory repository
A collection-like stand-in that implements the repository contract without a real database, typically used in tests
Creation method
A named factory method on an aggregate, such as Order.Place(), that starts the cluster in a valid state
Explicit save
A persistence-oriented style in which the caller must invoke a save operation for changes to become durable

8.8 Collaborative modeling: event storming and beyond

Big picture event storming
Wide exploration of a whole business flow
Design-level event storming
Detailed modeling of one process with commands and aggregates
Hot spot
Event storming note marking a question or conflict
Pivotal event
Key event marking a phase change in a flow
Example mapping
Clarifying rules with examples and questions
Wardley map
Map of components by visibility and evolution
DDD Crew
Community publishing open DDD modeling tools
Chaotic exploration
The opening burst of an event storming session in which people write events in parallel and place them roughly in time, before the group enforces a clean timeline
Unlimited modeling space
The long wall or zoomable board that lets a workshop keep adding facts instead of forcing early structure when the surface runs out
Fictitious event
A wishful business fact placed on an event storming wall and marked so it is not mistaken for something that already happens today
Software design event storming
A narrower event storming session that zooms into one process and adds design details such as commands, policies, aggregates, and read models
Event modeling
A structured, time-based modeling method, associated with Adam Dymitruk, that lays out views, commands, and events on a grid, often as specification slices
Impact mapping
A collaborative method, associated with Gojko Adzic, that starts from a goal, then the people who can help, then the impacts, and only then the deliverables
Domain message flow
A picture of how parts of a domain exchange messages or facts, often drawn after a workshop has named those parts, without first diving into their internals

8.9 Applying DDD: CQRS, event sourcing and when to use it

Event storming
Workshop mapping domain events to discover the model
DDD lite
Using tactical patterns without strategic design or language
Inverse Conway maneuver
Shaping teams to get the desired architecture
Team Topologies
Team types and interactions organized around flow
Stream-aligned team
Team owning a flow of change for one business area
Functional DDD
Modeling the domain with types and pure functions
Illegal states unrepresentable
Types that prevent invalid combinations
Write side
CQRS part where aggregates handle commands
Event-sourced aggregate
Aggregate whose state is rebuilt from its events
Domain-Driven Design Distilled
Vaughn Vernon's 2016 short DDD introduction
Learning Domain-Driven Design
Vlad Khononov's 2021 DDD book
Logical CQRS
A CQRS split in which a context keeps a distinct write model and one or more read models even when they are stored in the same database
Current-state persistence
Storing an aggregate as its latest values rather than as the sequence of facts that produced them
Read-model staleness
The delay that can exist between a write-side decision and a query view, which is a consistency choice for reads rather than a failed write-side invariant
Strategic-only DDD
Using language and bounded contexts as the main DDD investment, and keeping some interiors simple on purpose, without pretending that skipped modeling is a complete tactical design
Implementing Domain-Driven Design
Vaughn Vernon's longer, practitioner-focused DDD book, often called the red book, used as a companion to Evans rather than as a replacement for it
Domain Modeling Made Functional
Scott Wlaschin's book on modeling a domain with types and functions, especially workflows that become more precise as they proceed
Balancing Coupling in Software Design
Vlad Khononov's later book that treats integration in terms of strength, distance, and volatility rather than a single coupled-or-not label

Sample practice questions

  1. What is the ubiquitous language in DDD?

    1. A vocabulary shared by developers and domain experts, used in the code
    2. A programming language designed to run on every platform without changes
    3. Plain English, translated into every locale the product supports
    4. A list of approved acronyms maintained by the IT department

    Answer: A. A vocabulary shared by developers and domain experts, used in the code If the business says "policy" and the code says "contract record", the model has drifted.

  2. What is a bounded context?

    1. The scope of a single database transaction, from begin to commit
    2. An explicit boundary within which one model and its language apply
    3. The set of props that a UI component accepts from its parent
    4. A Kubernetes namespace that isolates a team's workloads

    Answer: B. An explicit boundary within which one model and its language apply The word "customer" can mean different things in Sales and Billing; each context has its own model.

  3. What is a context map?

    1. A geographic map showing where each of the data centers is located
    2. A JSON configuration file listing every service's settings
    3. A description of bounded contexts and how they relate and integrate
    4. A list of the database tables that each application uses

    Answer: C. A description of bounded contexts and how they relate and integrate It makes team and model dependencies visible.

  4. What defines an entity in DDD?

    1. A distinct identity that persists as its attributes change
    2. It's defined entirely by its attribute values, with no identity
    3. Any row stored in a relational database table
    4. A static utility class holding shared helper methods

    Answer: A. A distinct identity that persists as its attributes change A customer remains the same customer after changing address.

  5. What is an aggregate?

    1. The result set returned by a SQL query that uses GROUP BY
    2. Any collection of entities that happen to be loaded together
    3. Related objects changed as one unit through a root that enforces invariants
    4. A batch job that processes many records in a single run

    Answer: C. Related objects changed as one unit through a root that enforces invariants Example: an Order aggregate with its OrderLines, changed only through the Order root.

  6. What is the usual rule for transactions and aggregates?

    1. Modify every affected aggregate together in one large transaction
    2. Never use transactions at all when working with aggregates
    3. One aggregate per transaction; update others via events, eventually
    4. Give every individual property change its own transaction

    Answer: C. One aggregate per transaction; update others via events, eventually This keeps contention low and fits distributed systems.

  7. What is a domain service?

    1. Stateless domain logic that doesn't fit one entity or value object
    2. A REST endpoint that exposes the domain to outside callers
    3. A background Windows service that runs scheduled domain jobs
    4. A database stored procedure that holds the business rules

    Answer: A. Stateless domain logic that doesn't fit one entity or value object Example: a funds transfer between two accounts.

  8. What is event storming?

    1. A workshop where experts and developers map domain events on a timeline
    2. A load test that floods a system with events to find its breaking point
    3. A cloud monitoring dashboard that shows event volumes over time
    4. A cleanup technique for deleting old events from an event store

    Answer: A. A workshop where experts and developers map domain events on a timeline Alberto Brandolini created it; it quickly surfaces bounded contexts and aggregates.

  9. When is DDD most worth the effort?

    1. For every CRUD application, no matter how simple or complex it is
    2. Complex domains with rich rules, where expert collaboration pays off
    3. Only for video games, where the domain rules are especially complex
    4. Only for systems that don't use any kind of database at all

    Answer: B. Complex domains with rich rules, where expert collaboration pays off For simple CRUD, the tactical patterns can add needless ceremony.

  10. Who wrote the 2003 book that introduced Domain-Driven Design?

    1. Martin Fowler
    2. Eric Evans
    3. Vaughn Vernon
    4. Robert C. Martin

    Answer: B. Eric Evans Known as the "blue book."

Practice all 2,511 questions

More Architecture