RecapDifficulty: Advanced1 min

Recap: Facade Pattern

A simple front door for the common case, with the other doors left open.

Facade gives clients one simple class for the common jobs of a subsystem, and leaves the subsystem usable directly.

  • Intent. Provide a unified, higher-level interface to a set of interfaces in a subsystem, so it is easier to use.
  • Participants. The facade, the subsystem classes that do the work and do not know the facade, and the client.
  • Recognise it by shape. One class whose methods each call several other classes in a fixed order, translating the client's request into theirs.
  • Not a wall. The subsystem's classes stay public; a client that needs more control calls them.
  • In the wild. subprocess.run over Popen and communicate.
  • The trap. A facade connects and does not choose. Rules belong in the subsystem, or the facade becomes a god object.