STRUCTURAL PATTERNS / OBJECT DESIGN BRIEF

Facade pattern

The Facade pattern provides a simple, unified interface to a complex subsystem.

BeginnerPhase 05 / Topic 5 of 7ResponsibilitiesCollaborationsExtensibility
01

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.

A hotel concierge

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.

02

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.
03

Where it shows up in interviews

System entry point

Recognize it when: main class exposing the use cases.

  • Design an ATM
  • Design a home theater system
  • Design a library system
Simplifying integrations

Recognize it when: clients call 5 services for one task.

  • Design checkout
  • Design a video conversion library
04

Where it is used in real software

SLF4J LoggerFactory

A simple entry point over complex logging configuration.

Cloud SDK high-level clients

S3 TransferManager wraps multipart upload steps behind upload(file).

Backend for frontend

A BFF service is a facade combining many microservices for a UI.

05

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.
06

How it works, step by step

  1. 1
    Find the common client workflows

    placeOrder, watchMovie.

  2. 2
    Create a facade class

    Holds references to subsystem objects.

  3. 3
    Implement workflows as facade methods

    Coordinate calls in the right order.

  4. 4
    Keep subsystem accessible if needed

    Advanced clients may bypass the facade.

  5. 5
    Keep logic in the subsystem

    The facade orchestrates, it does not own rules.

07

Checkout with and without a facade

Client must reserve stock, price, charge, ship, notify

Step 1 / 3
AspectWithout facadeWith CheckoutFacade
Client calls5 services in the right ordercheckout.placeOrder(cart, card)
Order-of-operations bugsPossible in every clientHandled once
Changing shipping providerEvery clientFacade/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.

08

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;    }  }}
09

Complexity and performance

Client coupling1 class

Instead of many.

Runtime overheadNone meaningful

Just orchestration.

10

Trade-offs

Simplicity vs god object

Facades can grow into huge classes; split by use case or module.

Hiding power

Advanced features may be hidden; allow direct subsystem access when needed.

11

Variants and related techniques

Application service

In layered architectures, use-case services act as facades.

API gateway

A facade at the system level.

12

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.

13

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.

14

Practice problems

ProblemDifficultyWhat it trains
Home theater facadeEasyOrchestration.
Video conversion facade over codecs and muxersMediumHiding complexity.