Video in progress
What is a context map in DDD? When do you choose shared kernel, customer-supplier, conformist and open host service relationships?
A context map is a map of the relationships between bounded contexts: who depends on whose model, and how. The type of relationship reflects power and agreements between teams more than technology; if you name it up front, half of the integration problems never appear.
📖 Answer
The main ones and when I use them:
- Shared kernel. Two teams co-own a small shared model (for example,
Money,CustomerId). Only when the teams work closely and agree on changes together. Otherwise it quickly turns into a "common-model" swamp. Keep it small. - Customer–supplier. The downstream (customer) team puts its needs into the upstream's plan, and upstream changes the contract in agreement with them. The healthiest option between internal teams, but upstream's plan must really have room for it.
- Conformist. Downstream accepts the upstream model as it is: it can't influence it, and translating isn't worth it. For example, the statuses of an external payment system. Cheap, but your model gets tied to theirs.
- Anti-corruption layer. The opposite of conformist: the upstream model is bad or changes fast, and you shield yourself from it with a translation layer.
- Open host service + published language. Upstream provides a stable, documented API and format for many consumers (a versioned REST/event schema). The standard for platform teams.
- Separate ways. If integrating costs more than it's worth, don't integrate at all and duplicate the data.
In practice: at the start of a new integration I draw the map and give every link a name. This opens up questions: "Will the billing team put our need into their plan? If not, we have to be a conformist or build an ACL." Many problems come from this: a team thinks it's customer–supplier but is actually a conformist, and every upstream change causes an unexpected break.
The map is not a static document: if the organizational structure changes (Conway), the relationships change too, and the map has to be redrawn.
Sign up to mark studied questions and save your progress.