Anti-Corruption Layer
An Anti-Corruption Layer (ACL) is an architectural pattern, originating from Domain-Driven Design, that introduces a translation layer between two systems or bounded contexts with different data models or semantics, preventing the…
Definition
An Anti-Corruption Layer (ACL) is an architectural pattern, originating from Domain-Driven Design, that introduces a translation layer between two systems or bounded contexts with different data models or semantics, preventing the concepts, assumptions, or 'corruption' of one system's model from leaking into and polluting another.
Overview
The Anti-Corruption Layer pattern comes from Eric Evans' Domain-Driven Design (DDD), where a 'bounded context' represents a boundary within which a particular domain model and its terminology are consistent and well-defined. When two bounded contexts need to interact — for instance, a modern service integrating with a legacy system, or two systems acquired through a merger with incompatible data models — directly coupling one system's internal model to the other's risks 'corrupting' the cleaner or newer model with the older or foreign system's assumptions, naming conventions, and structural quirks. An Anti-Corruption Layer addresses this by introducing an explicit translation boundary: a set of adapters, facades, or translator components that sit between the two systems, converting requests and data from one system's model into the other's model and back again. Code on the 'clean' side of the ACL only ever interacts with its own well-designed domain model; all the messiness of translating to and from the external or legacy system's model is contained within the ACL itself, isolated from the rest of the application. This pattern is especially valuable during Strangler Fig-style incremental migrations, where a new system must communicate with a legacy system for an extended transition period. Without an ACL, the new system's codebase risks gradually absorbing legacy naming conventions, data quirks, and business rule assumptions simply through repeated direct interaction, undermining the very reason the new system was being built. The ACL contains that risk to a bounded, well-understood translation layer, which can be more easily modified or eventually removed once the legacy system is fully decommissioned. Anti-Corruption Layers are also common in integrations with third-party vendors or external partner APIs, where the external system's data model is outside the integrating team's control and likely to differ in structure, terminology, or business rules from the internal domain model, making direct coupling risky and brittle to external changes.
Key Concepts
- Introduces a translation boundary between two systems with differing domain models
- Originates from Eric Evans' Domain-Driven Design and the concept of bounded contexts
- Prevents a foreign or legacy system's model from leaking into a clean domain model
- Implemented via adapters, facades, or dedicated translator components
- Frequently used alongside the Strangler Fig pattern during incremental migrations
- Common in integrations with third-party vendors or external partner systems
- Isolates translation complexity to a bounded, replaceable layer
- Can be removed once the legacy or external dependency is no longer needed