Bookmarks

Bounded context

A boundary within which a single domain model holds and each of its terms has exactly one meaning; beyond the boundary the same word may mean something else.

Also: DDD context, context boundary

checked 8 Nov

All terms

In a large system, different teams describe the same thing differently: for sales a “customer” is a legal entity with a contract and a discount, for support it is a person with a ticket. A bounded context draws such a boundary: within it its own model and its own ubiquitous language apply, and between contexts the model is translated explicitly.

What defines the boundary

The boundary is set not by lines of code but by three things: which team works with the model, which piece of code belongs to it and where that model is applied. Within the boundary the model must be coherent — with no contradictions between terms. Fully unifying the model of a large system is impossible and too costly, so it is deliberately divided into contexts. The main factor behind the boundary is human: a different model is needed wherever the team’s language changes.

One term, one meaning

Consider an online shop: the same words live in three contexts and mean different things.

TermSalesSupportDelivery
customera legal entity with a contract and a discounta person with an open ticketthe address and recipient of a parcel
ordera deal with a basket and paymentthe source of a ticketa parcel with a tracking number

Because of this, a single company-wide “customer service” often fails: neighbouring contexts end up with different models of the same concept. Instead of a shared store, they need explicit translation at the boundary — for example, an exchange of events.

How contexts are joined

The connections between contexts are drawn on a context map: which contexts border which and how they translate their models. Typical ways of joining: a small fragment of the model that both contexts maintain together — the shared kernel, which Evans advises keeping small; a translator at the boundary that keeps a foreign model out — the anti-corruption layer; and an exchange of events. Microservices often coincide with contexts in their boundaries, but these are different concepts: a context is about the model, a service is about deployment.

The term was introduced by Eric Evans in the book Domain-Driven Design (2003): bounded context opens the part on strategic design — working with large models and teams.

Sources

the term is written from these pages

Verified 8 Nov

Not to be confused with

what it is mixed up with and how it differs

  • aggregate

    An aggregate is part of the model within a single context: it keeps related objects consistent; a context, by contrast, delimits the applicability of the whole model.

  • ubiquitous language

    The ubiquitous language operates only within a bounded context; beyond its boundary the same words already mean something else.

  • microservices

    The boundaries often coincide, but a microservice is a unit of deployment while a context is a boundary of the model: one context may span several services.

In depth in the references

where the topic is covered in detail