03 / 10

Facade Pattern

Difficulty: 5/10
encapsulation, subsystem integration, API simplification

The Facade pattern provides a simplified interface to a complex subsystem, hiding its complexities and making it easier to use.

The Facade pattern provides a unified, simplified interface to a set of interfaces in a subsystem, making it easier to use. It doesn't restrict access to the subsystem's internal functionality; rather, it offers a convenient entry point. This pattern is particularly useful for complex libraries, frameworks, or sets of APIs [citation:6].

Vanilla JavaScript Implementation
React Implementation
Angular Implementation

Scenario Questions

0-2 years experience

  1. 1We have a third‑party payment SDK with many classes and methods. How would you introduce a Facade to let the rest of the codebase make a single call like `processPayment(order)`?
  2. 2If you add a Facade around a file‑system library, what would happen if the underlying library throws an exception you didn’t anticipate?

2-5 years experience

  1. 1Our logging subsystem now goes through a Facade, but some log entries are missing context fields. What could be wrong in the Facade implementation?
  2. 2When refactoring a feature to use a Facade over several microservice clients, how do you decide which methods to expose versus keeping them private?

5-8 years experience

  1. 1Design a Facade for a service that aggregates data from three downstream APIs (REST, gRPC, and a legacy SOAP service). What latency, error‑handling, and versioning concerns would you address?
  2. 2In a high‑traffic e‑commerce platform, how would you use a Facade to isolate the checkout flow from frequent changes in the inventory and pricing subsystems while keeping performance overhead low?

8+ years experience

  1. 1Our monolithic order processing system is being split into microservices. How would you employ a Facade to provide a stable API for existing external partners during the migration?
  2. 2When multiple teams need to evolve different parts of a large legacy codebase, how can a Facade help enforce contract boundaries and reduce cross‑team coupling over the long term?

Follow-up Questions

  • What alternatives did you consider before choosing a Facade?
  • How would you verify that the Facade doesn't become a leaky abstraction?
  • Can you describe a situation where a Facade might add unnecessary indirection?
Share

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.