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:

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:

Map subdomains to BCs to decide where to invest modelling effort.

Anti-patterns

How to discover them

  1. Listen for synonyms — "invoice", "bill", "receipt" — same thing or different?
  2. Listen for homonyms — "user" in Auth ≠ "user" in CRM.
  3. Look at team boundaries — context borders often follow team borders (Conway's law).
  4. Look at lifecycles — entities with very different lifecycles often belong in different contexts.