Bounded context

What it is

A bounded context is an explicit boundary within which a particular
model and its language have a consistent meaning. A product can use
the word account for both access permissions and billing. For
access, an account might be the identity that can sign in. For
billing, it might be a relationship that can own invoices and
charges. A bounded context tells a team which rules and vocabulary
apply when it uses the term.

The boundary is about meaning and ownership. It can be implemented
as a module within one application, as a complete service or as an
agreement around a set of processes. Its shape follows the product
decisions that need to be made consistently and the groups that own
them. A deployment topology can reflect those decisions, but the
meaning of the model has to be understood first.

Contexts can share identifiers and exchange information. The
exchange benefits from an explicit contract. A billing model might
receive an identifier that connects a payer with an access account
and store only the details it needs for billing. It can give that
relationship a narrower meaning than the identity provider uses.
Making these translations visible helps preserve the vocabulary and
rules inside each context.

Why it matters

A team can use the same nouns in several parts of a product and
still be talking about different decisions. An order can be complete
for a warehouse once it is shipped. A finance team could consider it
complete only after payment settles. A support application might
keep it open until a return period ends. If the whole system shares
one general status field, each reader needs hidden knowledge to
interpret what the value means.

A defined boundary also helps an organisation choose who can change
a rule. The warehouse team can decide how shipment states behave.
Finance can use the facts it needs without adopting the entire
warehouse model. A contract between them should describe the facts
being exchanged and where consumers find their own truth. This gives
changes a route for review and makes reused words less likely to
spread incompatible assumptions.

The separation has a cost. Contexts need translations, ownership and
ways to discover how they relate. If every operation crosses several
boundaries just to complete one decision, the division may need
review. Start with a difference in meaning or responsibility that
people can explain. Use boundaries where they clarify actual
decisions and test the exchange where a user depends on both sides.

What it looks like in practice

Imagine a public directory of companies and a separate model of who
can manage their records. The directory describes published entries
and their visible information. The authority model describes a
relationship between an authenticated user and an organisation.
Someone can report a factual error in the directory while still
lacking authority to edit the record directly. Keeping those
meanings clear helps define the submission and approval workflow.

Engineer's company ownership and adjudication case study documents a
claim with evidence, an administrative approval step and an update
to the authorisation graph after approval. Those are concrete
decisions with distinct responsibilities. The illustrative model
uses one context for what is visible in the directory and another
for what a user is allowed to change. Give each context an explicit
definition of an approved relationship. The integration can then
translate that decision for the directory and for permissions.

Test the contract between the models. An approved claim may allow
editing immediately. A rejected claim can carry an explanation while
leaving the authority model unchanged. An update to the company name
should preserve the relationship to the organisation unless an
intentional change to authority accompanies it. Capture the
identifiers, status transitions and timing each side relies on.

Try one change in each direction. If publication changes the display
format, consumers of the authority decision should still recognise
the relevant organisation. If the rules of approval change, the
directory should still know which result it has to enforce. A test
that combines both changes can expose accidental shared assumptions
in names or identifiers.

Where it goes wrong

Naming packages after business areas is an easy first step and can
bring a false sense of precision. Check which part owns the
decisions people make. If a client calls several unrelated modules
to interpret one status, the contract may be incomplete. Measure how
often changes about one concept force edits across several parts of
the system.

Be cautious about duplicating rules in an integration adapter.
Translating an identifier or converting a published state can be
useful. Reimplementing the decision that granted authority can
create another source of truth. Test the published contract with a
known decision and check what the receiving system actually does.
Record any delay between the decisions and how users see it.

Ownership can also be unclear during recovery. Suppose a replay
delivers an old approval after authority has already been revoked.
The context that owns authority should apply its own transition and
ordering rules, and a receiving system can check the version of the
published state. The published directory's model of an edit request
needs a way to report an access decision without treating the
earlier approval as permanent. Write the recovery example where both
teams can test it.

Finally, review boundaries as the product changes. A new feature
might give a formerly shared word an additional purpose. Talk
through examples with the people who make the relevant decisions,
then update the contract and tests. A bounded context is useful when
its definition helps one team explain its own model and helps
another use the information it needs without guessing about the
rest.

Further reading

  * Microsoft Azure domain analysis for microservices. Explains
models, subdomains and bounded contexts.

  * Microsoft .NET domain model boundaries. Discusses shaping
application boundaries around business rules.

  * Microsoft Azure tactical domain-driven design. Describes
concepts used inside a model.

hThis page on the web	URL:https://engineer.company/glossary/bounded-context/	engineer.company	70
