Translate meaning before entering the domain
What This Concept Is
An anti-corruption layer translates another context's language into your domain's language. Parsing a field is only the first step: units, identity, lifecycle and error meanings must agree. The adapter owns the external schema; the domain owns its business rule.
Why It Matters Here
A partner may call a temporary hold a booking, while your sales context uses booking only for a confirmed purchase. Sharing one status enum conceals this disagreement. The context glossary should record the distinction before an adapter translates the codes.
Concrete Example
The synthetic partner contract uses v=1, code H, ref=a, units="002" to request reserve(a,2). Code R with ref=a requests release(a); units must be absent. Unknown code X is rejected, not interpreted as release. Only ASCII digits are accepted; negative values, whitespace, decimal notation and missing quantities are refused. Version True is rejected even though Python treats bool as an int subclass.
The translated reserve(a,2) can still be refused by a full pool. Translation success means the request was understood, not that the business operation succeeded. A network timeout means the outcome may be unknown; it is not a domain refusal or evidence that a release occurred.
Common Confusion / Misconception
An adapter that silently defaults unknown codes can turn version drift into an incorrect business action. Conversely, this lab's strict extra-field rejection can reject harmless additive evolution. Neither strictness nor tolerance is universally right: declare a compatibility policy and test it before changing the partner schema.
How To Use It
Keep external dictionaries and codes outside the core model. Test accepted and rejected examples, including version changes, unknown codes, units and missing fields. Preserve the external correlation identity in an application-level error record without inventing a successful domain event. Plan how a human or retry process handles quarantined messages; avoid logging sensitive raw payloads by default.
Check Yourself
Why may a syntactically valid message fail in the domain? What would be wrong with treating an unknown code as a no-op? How would you support a v2 schema whose quantities are in packs instead of individual units?
Mini Drill or Application
Write two context-specific definitions of reservation. Add three partner fixtures that parse successfully but must not translate under v1. Then propose a v2 adapter with an explicit unit conversion and compatibility tests. Keep domain commands unchanged only if their meanings remain unchanged.
Read This Only If Stuck
Learning Domain-Driven Design — context integration. Microsoft's anti-corruption-layer pattern explains semantic isolation and operational costs. This exercise needs no cloud account or paid service.