design·lab

Structural pattern

Facade

A facade wraps a complex set of subsystems behind one simple method, so callers don't need to know how the pieces fit together.

✗ The problem

The client must orchestrate everything itself

To watch a movie, the caller has to know every subsystem and the exact order to drive them in.

// client code — coupled to 4 subsystems:
amp.on();
amp.setVolume(5);
dvd.on();
dvd.play();
projector.on();
projector.wide();
lights.dim('30%');
The client is coupled to every subsystem and must know the exact sequence — get the order wrong and the movie doesn't start right.
✓ The pattern

Hide the sequence behind one method

The facade knows the subsystems and their order. The client just calls watchMovie().

class HomeTheaterFacade {
  constructor(amp, dvd, proj, lights) {
    // store the subsystems
    Object.assign(this, {amp, dvd, proj, lights});
  }

  watchMovie() {
    // one call, right order, always
    this.amp.on();
    this.dvd.play();
    this.proj.on();
    this.lights.dim('30%');
  }
}
Client
HomeTheaterFacade
watchMovie()
Amp
DVD
Projector
Lights
✓ See it live

One call, four subsystems fall in line

Click watchMovie() and watch the facade drive each subsystem in order. Toggle the manual view to see what the client would otherwise have to write.

Client
HomeTheaterFacade
🔊 Amp
off
📀 DVD
off
📽️ Projector
off
💡 Lights
100%
ready
✓ Takeaway

Simplify the entrance, not the system

  • One simple entry point sits in front of a complex subsystem.
  • Reduces coupling and cognitive load — callers stop tracking sequencing rules.
  • Doesn't hide the subsystem — advanced callers can still reach amp, dvd, etc. directly when they need to.
  • Not the same as: Adapter converts one interface to another; Decorator adds behavior. Facade just simplifies access to several things at once.
  • Careful: don't let the facade grow into a god-object that does everything itself.
🎯 Principle applied: Facade cuts coupling and honors the Law of Demeter (talk to one object, not a dozen), and gives subsystem orchestration a single responsibility.