Course contentsShow
← Software Engineering
Lesson 1776 of 1,93351. Legacy Code and Brownfield DevelopmentFree lesson

Implementing the Facade Layer

Creating an abstraction layer that routes requests between legacy and new systems during the transition period.

Implementing the Facade Layer

You'll learn how to create the crucial abstraction layer that safely routes traffic between your legacy system and its modern replacement during migration.

When applying the Strangler Fig Pattern, you need a "traffic cop" at the boundary between old and new systems. The facade layer is this intelligent router that sits in front of both systems, deciding which requests go where while presenting a single, unified interface to clients.

What the Facade Layer Does

Think of the facade as a receptionist at a building being renovated. Some departments have moved to a new wing, others are still in the old offices. The receptionist knows exactly where to send visitors—and visitors don't need to know or care about the construction happening behind the scenes.

The facade layer:

  • Routes requests to either legacy or new system based on migration state
  • Translates data formats between incompatible systems if needed
  • Provides a unified interface so clients don't know about the migration
  • Enables gradual cutover by letting you shift functionality piece by piece

Implementation Strategy

Start by identifying the seam you established when defining strangulation boundaries. Place your facade at this seam. Initially, it routes 100% of traffic to the legacy system. As you build replacement components, update the facade's routing logic to send specific requests to the new system.

The facade might check feature flags, user segments, or request types to make routing decisions. It handles response translation when necessary, ensuring consistency regardless of which backend served the request.

Key Takeaway: The facade layer is your safety valve during migration—it abstracts away the complexity of running two systems in parallel, giving you fine-grained control over what gets migrated when, with the ability to roll back at the routing level if issues arise.