Bounded Context & Ubiquitous Language
Bounded Context & Ubiquitous Language
Two strategic-DDD concepts that you cannot separate: a bounded context is the area inside which one consistent ubiquitous language applies.
The problem they solve
Same word, different meaning. Order, User, Account, Product — every team uses these terms, but they mean different things inside each subsystem.
| Word | Meaning in Sales |
Meaning in Shipping |
Meaning in Billing |
|---|---|---|---|
| Order | Draft cart with line items | Package with a tracking number | Invoice with tax |
| Customer | Registered user with a wishlist | Delivery address | Payer with a credit limit |
A single Order class trying to satisfy all three becomes a god object — slow, fragile, confusing.
What a Bounded Context is
A bounded context is a model boundary. Inside it:
- One shared language (the ubiquitous language).
- One model with consistent meanings.
- Owned by one team (ideally).
- Its own database schema (recommended).
Crossing the boundary requires translation — explicit mapping between models.
Ubiquitous Language
The language used by the domain experts AND the code AND the tests AND the conversations.
If an expert says "a Loan becomes Overdue when its due_date is past and Returned is false", the code reads:
def is_overdue(self, today: date) -> bool:
return self.due_date < today and not self.returned
Not is_late, not is_expired. Match the expert's vocabulary exactly.
Context Map: how contexts relate
| Pattern | When |
|---|---|
| Shared Kernel | Two teams share a small overlapping model |
| Customer / Supplier | One context depends on another; supplier accommodates |
| Conformist | One context takes the supplier's model as-is |
| Anti-Corruption Layer (ACL) | Translation layer to protect from a messy upstream |
| Open Host Service | Stable public API for many downstream consumers |
| Published Language | Documented schema (JSON Schema, protobuf) |
Subdomains
Orthogonal to BCs, every domain has subdomains:
- Core — what differentiates the business. Build in-house. Spend modelling effort here.
- Supporting — necessary but not differentiating. Build if no good off-the-shelf option exists.
- Generic — solved by industry (auth, payments, mail). Buy / use a library.
Map subdomains to BCs to decide where to invest modelling effort.
Anti-patterns
- Canonical Enterprise Data Model. One
Customerclass for the whole company. Doesn't survive contact with reality. - Shared database across contexts. Couples schemas; loses the model boundary.
- Same class name across contexts without translation. Silent semantic drift.
- Mapping bounded contexts 1:1 to microservices. Sometimes right, often premature. Modular monolith first.
How to discover them
- Listen for synonyms — "invoice", "bill", "receipt" — same thing or different?
- Listen for homonyms — "user" in Auth ≠ "user" in CRM.
- Look at team boundaries — context borders often follow team borders (Conway's law).
- Look at lifecycles — entities with very different lifecycles often belong in different contexts.