Skip to content

Field Guide

The anti-corruption layer: keeping Gen 1's model out of Gen 2

Gen 2 has to talk to Gen 1 for as long as both are running. Without a boundary, every one of those calls drags a little of the old design into the new system.

Slide: Gen 2, which speaks only its own model, and Gen 1, the legacy model, with an anti-corruption layer between them that translates both ways.

A Gen 2 that has to call Gen 1 will be tempted to speak Gen 1's language. The old customer record has 140 columns and a status code nobody can explain, so the new code starts carrying 140 fields and the same status code. A year later Gen 2 has the old design inside it, and the rewrite has rebuilt the thing it was meant to replace.

The anti-corruption layer is the boundary that stops that. Microsoft's pattern description credits it to Eric Evans, who "first described this pattern in Domain-Driven Design: Tackling Complexity in the Heart of Software."

What it is

Microsoft's one-line definition: "Implement a facade or adapter layer between different subsystems that don't share the same semantics. This layer translates requests that one subsystem makes to the other subsystem."

The rule that makes it work is about which side speaks which language. "Communication between subsystem A and the anti-corruption layer always uses the data model and architecture of subsystem A. Calls from the anti-corruption layer to subsystem B conform to that subsystem's data model or methods." Gen 2 talks to the layer in Gen 2's terms. Only the layer knows how Gen 1 works.

Why a migration needs one

Microsoft describes the exact situation of a gradual Gen 1 to Gen 2 project: "when you migrate a legacy application to a modern system, the application might continue to use existing legacy resources. New features must be able to call the legacy system."

And the cost of doing that directly: "When you maintain access between new and legacy systems, you force the new system to adhere to at least some of the legacy system's APIs or other semantics. When these legacy features have quality problems, this support corrupts what might otherwise be a cleanly designed modern application."

The traffic runs the other way too. AWS describes the strangler fig case, where a feature has moved to the new service and the old system still needs it: "the calls should be routed to the migrated service without requiring any changes to the calling services." The layer lets Gen 1 call Gen 2 in Gen 1's old terms while Gen 2 keeps its new ones.

What goes inside it

  • Translation of data. Gen 1's record in, Gen 2's object out, and back.
  • Translation of meaning. A status code of 7 in Gen 1 might be two separate facts in Gen 2. The layer is where that mapping is written down once.
  • Protocol and format. SOAP to JSON, fixed-width files to events, a stored procedure to a method call.

What does not go inside it is business logic. Microsoft is explicit: "focus the anti-corruption layer on translation logic. Avoid placing business rules or orchestration in the layer." A layer that starts making decisions becomes a third system nobody planned.

The costs

Both clouds list the same price tag:

  • Latency. Every call takes an extra hop. AWS recommends you "define and test performance tolerance" before the layer reaches production.
  • One more thing to run. Monitoring, releases, configuration and on-call for a component that ships no feature of its own.
  • A single point of failure. AWS: "Any failures in the ACL can make the target service unreachable." Retries, circuit breakers and alerts belong in the design from the start.
  • Scaling. If the systems on either side scale with load, the layer has to as well.

Temporary on purpose

The most important decision is whether the layer is permanent. Microsoft asks it directly: "If the anti-corruption layer is part of an application migration strategy, consider whether it's permanent or whether you plan to retire it after you migrate all legacy functionality."

AWS answers it for migrations: "If it's an interim solution, you should record the ACL as a technical debt and decommission it after all dependent callers have been migrated." Put the layer's removal on the same plan as killing Gen 1. When Gen 1 is gone, there is nothing left to translate.

When you do not need one

Microsoft lists one case where the pattern might not be suitable: "The new and legacy systems have no significant semantic differences." If Gen 2 is a port of the same model to a new platform, a translation layer adds latency and code for nothing. The test is simple: write down what the same customer, order or account means in each system. If the two descriptions match, skip the layer.

Where it goes wrong

  • The layer leaks. One Gen 1 field is passed through as a stopgap, then another. Review the layer's outputs against Gen 2's model, not Gen 1's.
  • Business rules move in. It becomes the only place a rule exists, and it cannot be retired.
  • Nobody owns it. It sits between two teams and belongs to neither, so it is the last thing fixed when it breaks.
  • It outlives Gen 1. The old system is switched off and the layer keeps running, translating for nobody.

Checklist

  • Gen 2 calls the layer only in Gen 2's terms; nothing in Gen 2 imports a Gen 1 type.
  • Each translated field and code is written down once, in the layer.
  • No business rule lives only in the layer.
  • Latency is measured and has a stated limit; failures are retried and alerted on.
  • The layer has one owning team.
  • Its retirement is recorded as debt, with the same end date as Gen 1.

The layer pairs naturally with branch by abstraction, which puts a seam inside the code, and with dual write, which keeps the data in step while both generations are live.

Sources

  1. Anti-corruption Layer pattern - Azure Architecture Center (Microsoft) - the definition, the legacy migration problem, the considerations, and when not to use it; credits Eric Evans's Domain-Driven Design
  2. Anti-corruption layer pattern - AWS Prescriptive Guidance - the monolith-to-microservices version, recording a temporary layer as technical debt, and decommissioning it

Last updated November 29, 2026.