How it works · 9 of 49 Core

What is a bounded context in domain-driven design?

The same word, different meanings

Bounded contexts: A bounded context is the part of a system inside which one model, and one meaning for each word, holds. "Customer" is a lead to Sales, a payer to Billing, a delivery address to Shipping; instead of one giant Customer every part must agree on, each context keeps its own small model, they share only an id, and a translation sits where they meet. The cost is that translation, and deciding where the borders run.

Loading the animation…

Say it like this A bounded context is where one meaning of a word holds; give each part its own model, share only ids, and translate where they meet.

Under the hood — for builders
The sources, in their words
Eric Evans, Domain-Driven Design Reference (2015): "Model expressions, like any other phrase, only have meaning in context." Therefore: "Explicitly define the context within which a model applies." Martin Fowler (2014) met it at an electricity utility, where "meter" meant the grid-to-location connection, the grid-to-customer connection or the physical meter, depending on who was talking; he sees the same with "Customer" and "Product".
This card's customer, island by island
Bounded context: the part of the system inside which one model and one meaning of each word hold. Each island keeps three fields; only the id is in all four. One shared Customer would carry all of them, and every island would depend on every field.
Where the islands meet
Evans calls the drawing of contexts and their contact points a context map: "Map the existing terrain. Take up transformations later." Two of the relationships it names are in the scene's last beat:
Anticorruption layer
The downstream side builds "an isolating layer" that gives it the other system's functions "in terms of your own domain model", translating at the border. The scene's piers.
Conformist
The downstream side "slavishly" adopts the upstream model: no translation, a cramped model. Cheap when upstream won't change for you. Support conforming to Billing.
Measure it
Words defined differently by two teams (list them) · fields that cross a border besides ids · changes that needed sign-off from another context.
Watch out
A context per team at first; split further only when the language splits. Sharing one table across contexts quietly merges them again.
Sources
Fowler, "BoundedContext", martinfowler.com, 15 Jan 2014 · Evans, "Domain-Driven Design Reference", 2015 (Bounded Context, Context Map, Anticorruption Layer, Conformist); both read in session.

What happens in the bounded contexts animation, step by step?

  1. One real person, four departments. On the Sales island, "Customer" means a lead: someone who might buy.
  2. Try one Customer for the whole company: the card holds every field anyone needs, and every island must agree on every change.
  3. Your turn: tap an island and ferry the customer across.
  4. Each island keeps its own small model. Only the id crosses the water; the pier translates the rest.
  5. A change in Billing stays in Billing. With the giant card, all four would have had to agree.
  6. Name the islands and the routes between them: a context map. Next: a small core that others extend.

What everyday example explains bounded contexts?

The same person at a bank counter and at the IT help desk. "Account" means money at one and a login at the other; nobody tries to make one form that serves both.

Why should a team care about bounded contexts?

When a meeting stalls on what "customer", "order" or "account" really is, the answer is usually "it depends where": draw the borders, give each side its own model, share ids, and translate at the edge. The same borders are the natural seams for B3's packages and module C's services.