Design Patterns

Façade



Design Pattern Type: Structural

GoF Statement of Intent:


Provide a unified interface to a set of interfaces in a subsystem. Façade defines a higher-level interface that makes the subsystem easier to use.
Brief Overview:



The façade provides a simplified interface to a larger body of code. The façade can:
  1. Make a software library easier to use and understand and test by providing convenient methods to accomplish complicated tasks.
  2. Wrap a poorly designed collection of APIs with a single well-designed API
The primary purpose of a façade is to provide a simpler, easier interface to work with.

UML Diagram:

Discussion and In-class Example:

In the Facade Design Pattern we used the example of creating a really super-cool home theater system that integrates a multitude of pieces of equipment, but unfortunately we are left with a basket full of remote devices and a long list of actions we have to execute just to watch a movie.



But the Facade pattern lets us greatly simplify that process. By encapsulating all the separate remote control actions (calls to many different functions in many different classes) into a single Facade class we let it take care of all the complicated stuff with a simple call to watchMovie().