top of page

What is an Anti-Corruption Layer?

In Domain-Driven Design (DDD), the Anti-Corruption Layer (ACL) is a design pattern that helps maintain the integrity of your domain model when interacting with external systems or legacy systems that don't follow the same design principles.


Purpose of the Anti-Corruption Layer

The purpose of the Anti-Corruption Layer is to isolate your domain model from external or legacy systems that may not align with the structure, terminology, or business rules of your core domain. This is especially useful when you're working with systems that are outside your control or have different design philosophies, such as older systems, third-party APIs, or systems following different bounded contexts.


Key Concepts:


Boundary Protection: The ACL acts as a boundary between your core domain and the external system. It translates concepts, data formats, and interactions between the two systems so that the integrity of your domain model is maintained.


Translation Layer: The ACL maps concepts and data from the external system to your domain model. This includes:


Converting data structures from the external system into your domain’s objects.

Translating terminology or business logic so that it fits within your domain's understanding.

Preventing Pollution: Without the ACL, an external system could "pollute" your domain model with concepts, terminology, or structures that don’t align with your domain. By using the ACL, you prevent external models from influencing or corrupting the internal logic and design of your domain.


Decoupling: By introducing an Anti-Corruption Layer, you decouple your system from external systems. This makes it easier to replace or change external systems without affecting your core domain logic.


How It Works:

Inbound Translation: When your domain needs to consume data or interact with an external system, the ACL translates the external data into your domain’s language, ensuring that your domain remains consistent with its own rules and logic.


Outbound Translation: When your domain needs to send data or make a request to an external system, the ACL translates your domain's structures and concepts into the format and language that the external system understands.

bottom of page