Structural Patterns  «Prev  Next»

Facade Pattern

Facade Pattern Description:

The Facade pattern provides a unified interface to a group of interfaces in a subsystem.
The Facade pattern defines a higher-level interface that makes the subsystem easier to use because you have only one interface. This unified interface enables an object to access the subsystem using the interface to communicate with the subsystem.
The figure below illustrates the Facade pattern.

Facade Pattern


The following lists the benefits of using the facade pattern.
  1. Provides a simple interface to a complex system without reducing the options provided by the system.
  2. Shields clients from subsystem components.
  3. Promotes weak coupling between the subsystem and its clients.
  4. Reduces coupling between subsystems if every subsystem uses its own Facade pattern and other parts of the system use the Facade pattern to communicate with the subsystem.
  5. Translates the client requests to the subsystems that can fulfill those requests.

Facade Pattern Code

When To Use:

You should use the Facade pattern when:
  1. You want to provide a simple interface to a complex subsystem.
  2. There are many dependencies between clients and implementation classes of an abstraction.
  3. You want to layer your subsystems.