Facade Pattern
ELI5 — The Vibe Check
Facade Pattern is like the front desk at a hotel. You don't call housekeeping, maintenance, and the kitchen separately — you call the front desk and they coordinate everything. A facade provides a simple interface to a complex subsystem, hiding all the messy coordination.
Real Talk
The Facade pattern provides a simplified interface to a complex subsystem of classes, libraries, or frameworks. It doesn't prevent direct access to the subsystem but provides a convenient higher-level interface. Reduces complexity for common use cases and decouples clients from implementation.
Show Me The Code
// Facade hides complex subsystem
class HomeTheaterFacade {
turnOn() {
this.amp.on();
this.projector.on();
this.speakers.setVolume(10);
this.lights.dim(50);
}
}
When You'll Hear This
"Create a facade over these three payment services." / "The SDK is a facade over the raw HTTP API."
Related Terms
Abstraction
Abstraction is hiding the messy details and showing only what matters.
Adapter Pattern
You're in Europe with a US charger. You need an adapter. In code, your app expects a PaymentProcessor with a .pay() method, but the new Stripe SDK uses .
API Gateway Pattern
An API gateway is the front door for all your microservices.
Design Pattern
Design patterns are like recipe cards for solving common coding problems.