Mapa de Contextos
Escrito por Darjus Kazakevic · revisado el
A drawing of how your contexts really depend on each other, ugly parts included.
A context map is a drawing of your bounded contexts and the links between them. Each link has a direction and a relationship type. Upstream is the side whose changes flow out; downstream is the side that must react. In an online shop, Sales is upstream of Shipping: when the order event changes, Shipping adapts.
Its main value is honesty. Draw the system as it is, including the legacy ERP everyone copies and the database two teams secretly share. A map of only the planned design hides the links that hurt.
En esencia — Draw every link between bounded contexts and name its type, so everyone can see who depends on whom and who pays when one side changes.
Cuándo recurrir a él
Recurre a él cuando
- More than three bounded contexts are in play
- Planning a migration or a split of a legacy system
- Changes in one team keep breaking another team by surprise
Reconsidéralo cuando
- A single context: there is nothing to map yet
- A one-off drawing that nobody will keep current
- A small system whose teams all sit in one room
The relationship vocabulary
- Upstream and downstream
- The direction in which change flows. Upstream changes reach downstream whether downstream likes it or not, so downstream pays for most of the adapting.
- Working together
- Partnership and shared kernel. Two teams accept the coupling and manage it jointly, by planning releases together or by co-owning a small piece of code.
- Upstream leads
- Customer–supplier and conformist. Upstream serves downstream; the only difference is whether downstream has a say in the contract.
- Protect, publish or stay apart
- Anti-corruption layer, open host service, published language and separate ways. These are the options when cooperation is not available or not worth it.
Mapping well
- Label every link with a relationship type
- An unlabelled arrow only says that two contexts talk. The label (conformist, ACL, shared kernel) says who pays when either side changes, which is why you draw the map.
- Draw today's map before the target map
- Map the current reality first, bad couplings included, and only then the target. The difference between the two maps is your integration plan.
- Expect the map to follow the org chart
- Context links usually follow team relationships, not technical merit (Conway's law). When the map looks irrational, the cause is usually organisational, and so is the fix.
- Keep it small enough to redraw
- A map is useful only while it is current. A whiteboard photo or a short text file that people update beats a detailed model that nobody touches.
Errores habituales
- Drawing the wished-for design and calling it the map
- Arrows with no relationship type, so nobody knows who pays
- Leaving out third-party and legacy systems, usually the worst links
- Treating it as a one-time deliverable instead of a living file