EMZETT.
Login

Facade pattern

In short: A facade provides a simple interface in front of a complicated subsystem. Callers only need to know the facade.

In more detail: Instead of a program working with ten classes of a subsystem individually, it calls one method of the facade, which coordinates the details. This lowers coupling and makes code more readable.

In Depth

  • Example: VideoConverter.convert(file, "mp4") hides codec selection, decoding, scaling and encoding.
  • Distinction: The adapter adapts an existing interface to an expected one, the facade simplifies a complex one.
  • Risks: An oversized facade becomes a “god object”.
  • Common: libraries that lay a simple API over many individual parts.

See also: Adapter, Abstraction