What is Anti-Corruption Layer
Isolation from external data models
Anti-Corruption Layer (ACL)
Anti-Corruption Layer is an architectural pattern from Domain-Driven Design (DDD) that protects your domain model from external system influence through a translation layer.
Why It's Needed
| Problem | Solution | |---------|----------| | External model differs from internal | ACL translates data | | Legacy system with outdated API | Adaptation without core changes | | Third-party service integration | Dependency isolation | | Migration to new architecture | Gradual transition |
ACL Components
- Translator — data transformation between models
- Facade — simplified interface to external system
- Adapter — protocol and format adaptation
- Gateway — entry point for external requests
When to Apply
- Legacy system integration
- Working with different API versions
- Microservice transitions
- Protection from external system changes
Advantages
- Domain model purity
- Independence from external changes
- Gradual migration capability
- Business logic testability