Chapter I · Area 04 of 12

Domain Modelling & DDD

The Question for Our ShopDo order and invoice mean the same thing when both speak of an “amount”?

Learn how domain language, models and responsibilities shape your design.

Three questions for every domain model

  1. Which words apply?

    Language

    The shop team defines order, reservation, authorisation and invoice, each with a verifiable meaning.

  2. Where does each model apply, and how do models relate?

    StrategicStrategic design

    Order and invoice are separate contexts; an ACL translates the payment provider’s codes.

  3. What must remain consistent within a model?

    TacticalTactical design

    B-1042 needs at least one line item; two amounts of €49.90 are the same value.

Known names – and where they are

This is how the building blocks hang together

Domain-driven design connects domain knowledge and model. Ubiquitous language sharpens terms, bounded contexts mark where they are valid, value objects and aggregates shape states, and the context map and ACL govern the transitions.

ConceptBounded ContextA bounded context defines where a domain model and its terms apply.ApproachDomain-Driven Designorganises modelling around domain knowledge and uses bounded contexts as the key boundaryPrincipleUbiquitous Languagekeeps terms and rules consistent within a contextConceptAggregateprotect invariants within a clear consistency boundaryConceptEntities & Value Objectsdistinguishes values from objects with identity within a bounded contextArtifactContext Mappingshows direction and collaboration between bounded contextsPatternAnti-Corruption Layertranslates foreign terms into the language of your own model
Relations: Domain-Driven Design organises modelling around domain knowledge and uses bounded contexts as the key boundary; Ubiquitous Language keeps terms and rules consistent within a context; Aggregate protect invariants within a clear consistency boundary; Entities & Value Objects distinguishes values from objects with identity within a bounded context; Context Mapping shows direction and collaboration between bounded contexts; Anti-Corruption Layer translates foreign terms into the language of your own model.

Your learning path through the area

Domain modelling clarifies which words apply in the shop, where a model ends and how models relate. That way order and invoice do not mean the same by “amount”, and every rule has its place. Each building block shows its theme at our shop.

  1. Domain-Driven Design

    Overview & comparison

    This is what you learnYou can classify subdomains as core, supportive, or generic and steer the modeling effort accordingly.

    In the shopIn the shop, not all modules are equally important. The order rules distinguish him, the payment he buys from the payment provider. The team then adjusts its modelling effort.

    Domain-Driven Design Open
  2. Subdomain

    Standalone concept

    This is what you learnDistinguish subdomains by business importance and align architecture effort.

    In the shopThe shop remains a modular monolith with seven business modules and a shared deployment.

    Subdomain Open
  3. Domain service

    Standalone concept

    This is what you learnModel and independently test business rules with no natural object owner.

    In the shopThe shipping-eligibility rule checks values from ordering, catalog and shipping options in the seven-module shop.

    Domain service Open
  4. Event Storming

    Standalone concept

    This is what you learnExplore domain event sequences collaboratively and derive model questions that can be validated.

    In the shopThe shop case covers seven modules in one shared deployment. The payment provider remains external.

    Event Storming Open
  5. Ubiquitous Language

    Standalone concept

    This is what you learnYou can replace ambiguous shop terms with precise technical terms that are uniform in the respective context.

    In the shopThe shop team clarifies the words order, reservation, authorization and invoice. Each term receives a testable meaning in the appropriate context.

    Ubiquitous Language Open
  6. Bounded Context

    Standalone conceptStrategic

    This is what you learnYou can define the scope of a model by your own terms, rules and responsibility.

    In the shopOrder and invoice are two contexts in the shop. Both know an amount and a status, but use these terms for different business purposes.

    Bounded Context Open
  7. Entities & Value Objects

    Overview & comparisonTactical

    This is what you learnYou can distinguish objects with persistent identity from immutable business values.

    In the shopOrder B-1042 Despite the change of status, the same order remains. Two sums of money from 49,90 EUR are technically the same as soon as the amount and currency match.

    Entities & Value Objects Open
  8. Value object

    Standalone concept

    This is what you learnDesign value objects as value-equal business units and centralise their rules.

    In the shopThe two mugs in B-1042 cost 49.90 EUR in total. Compare identical amounts, different currencies and matching address details. The USD variant is used only for comparison.

    Value object Open
  9. Entity

    Standalone concept

    This is what you learnDistinguish entity identity from mutable attributes and reason about business state changes.

    In the shopFollow B-1042 from creation to confirmation. Then compare B-1042 with a hypothetical second order, B-1043: identical items do not make them the same order.

    Entity Open
  10. Aggregate

    Standalone conceptTactical

    This is what you learnYou can set a consistency boundary and make changes about its business root.

    In the shopOrder B-1042 contains positions and a delivery address. Their rules require at least one position, a positive amount per position and an order sum that matches the positions.

    Aggregate Open
  11. Factory

    Standalone concept

    This is what you learnCreate valid domain objects with explicit construction rules.

    In the shopThe order factory creates the aggregate; the repository stores it. Both belong to the Ordering module.

    Factory Open
  12. Repository

    Standalone concept

    This is what you learnDesign a repository as a domain-facing gateway to stored aggregates and distinguish it from table access.

    In the shopThe Ordering module owns order data; Stock manages its reservations within the same modular monolith.

    Repository Open
  13. Context Mapping

    Overview & comparisonStrategic

    This is what you learnYou can describe relationships between business contexts with direction, information exchanged, and translation.

    In the shopIn the shop, there are relationships within the team, in which warehouse, payment and order are coordinated. Externally, there is a relationship with the payment provider, whose model does not influence the shop.

    Context Mapping Open
  14. Open Host Service

    Standalone concept

    This is what you learnProvide a reusable upstream capability as a stable contract for several consumers.

    In the shopThe shop remains a modular monolith with seven modules and a shared deployment; this relationship describes model ownership.

    Open Host Service Open
  15. Conformist

    Standalone concept

    This is what you learnDeliberately accept an asymmetric upstream dependency and protect against its effects.

    In the shopThe shop remains a modular monolith with seven modules and a shared deployment; this relationship describes model ownership.

    Conformist Open
  16. Customer-Supplier

    Standalone concept

    This is what you learnManage dependencies between contexts cooperatively and define the Customer’s influence.

    In the shopThe shop remains a modular monolith with seven modules and a shared deployment; this relationship describes model ownership.

    Customer-Supplier Open
  17. Shared Kernel

    Standalone concept

    This is what you learnKeep a jointly owned model fragment small and coordinate its change explicitly.

    In the shopThe shop remains a modular monolith with seven business modules and a shared deployment.

    Shared Kernel Open
  18. Anti-Corruption Layer

    Standalone conceptStrategic

    This is what you learnYou can translate a foreign data model into your own specialist model at an integration boundary.

    In the shopThe payment provider provides the codes APPROVED, DECLINED and PENDING_REVIEW. The shop uses its own states authorized, rejected and clarification is ongoing.

    Anti-Corruption Layer Open
Afterwards in the learning path · area 05Styles & patterns