Overview
The Facade pattern provides a simple, unified interface to a complex subsystem. Instead of clients coordinating inventory, pricing, payment, and shipping services themselves, an OrderFacade.placeOrder() does it. The subsystem classes remain available for advanced use, but most clients only need the facade.
Facades reduce coupling between clients and subsystem internals, make common tasks easy, and provide a natural boundary for modules. In LLD interviews, the main service class (ParkingLot, ATM, Library) often acts as a facade over many collaborating objects.
You ask the concierge for dinner, a taxi, and theater tickets. The concierge talks to restaurants, taxi companies, and box offices so you do not have to.
When to use it
- Clients repeat multi-step coordination across several classes.
- Hiding a complex or legacy subsystem behind a simple API.
- Defining a module's entry point.
Where it shows up in interviews
Recognize it when: main class exposing the use cases.
- Design an ATM
- Design a home theater system
- Design a library system
Recognize it when: clients call 5 services for one task.
- Design checkout
- Design a video conversion library
Where it is used in real software
A simple entry point over complex logging configuration.
S3 TransferManager wraps multipart upload steps behind upload(file).
A BFF service is a facade combining many microservices for a UI.
Key terms
- Facade
- Simplified entry point to a subsystem.
- Subsystem
- The set of classes doing the actual work.
- Coupling reduction
- Clients depend on one class instead of many.
How it works, step by step
- 1Find the common client workflows
placeOrder, watchMovie.
- 2Create a facade class
Holds references to subsystem objects.
- 3Implement workflows as facade methods
Coordinate calls in the right order.
- 4Keep subsystem accessible if needed
Advanced clients may bypass the facade.
- 5Keep logic in the subsystem
The facade orchestrates, it does not own rules.
Checkout with and without a facade
Client must reserve stock, price, charge, ship, notify
| Aspect | Without facade | With CheckoutFacade |
|---|---|---|
| Client calls | 5 services in the right order | checkout.placeOrder(cart, card) |
| Order-of-operations bugs | Possible in every client | Handled once |
| Changing shipping provider | Every client | Facade/subsystem only |
NOWAspect: Client calls | Without facade: 5 services in the right order | With CheckoutFacade: checkout.placeOrder(cart, card)
The facade encodes the workflow once; clients stay simple.
Implementation
class CheckoutFacade { constructor( private inventory: InventoryService, private pricing: PricingService, private payments: PaymentGateway, private shipping: ShippingService, private notifier: Notifier, ) {} async placeOrder(userId: string, cart: CartItem[], card: string) { const reservation = await this.inventory.reserve(cart); try { const total = this.pricing.total(cart, userId); const payment = await this.payments.charge(card, total); const shipment = await this.shipping.schedule(userId, cart); await this.notifier.orderPlaced(userId, shipment.trackingId); return { paymentId: payment.id, trackingId: shipment.trackingId, total }; } catch (err) { await this.inventory.release(reservation); throw err; } }}Complexity and performance
Instead of many.
Just orchestration.
Trade-offs
Facades can grow into huge classes; split by use case or module.
Advanced features may be hidden; allow direct subsystem access when needed.
Variants and related techniques
In layered architectures, use-case services act as facades.
A facade at the system level.
Common mistakes
- Putting business rules in the facade.
Fix: Keep rules in domain objects; the facade orchestrates.
- One facade for the entire application.
Fix: One per subsystem or bounded context.
Interview questions
Facade vs Adapter?
A facade defines a new, simpler interface over several classes; an adapter converts one existing interface into another expected interface.
Is the main class in an LLD solution a facade?
Often yes: ParkingLot or ATM exposes the main use cases and coordinates floors, spots, pricing, and payment objects behind simple methods.
Practice problems
| Problem | Difficulty | What it trains |
|---|---|---|
| Home theater facade | Easy | Orchestration. |
| Video conversion facade over codecs and muxers | Medium | Hiding complexity. |