Design Patterns - Facade Pattern
15 Jul 2018Intent
Provides a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use. - Gang of Four
Intent | You want to simplify how to use an existing system. You need to define your own interface. |
Problem | You need to use only a subset of a complex system. Or you need to interact with the system in a particular way |
Solution | The Facade presents a new interface for the client of existing system to use |
Participants and Collaborators | The Facade simplifies the use of the required subsystem. However, because the Facade is not complete, certain functionality may be unavailable to the client |
Implementation | Define a new Class or classes that have the required interface. Have this new class use the system |
Summary
- Allows us to avoid tight coupling between Clients and Subsystems
- Facade still leaves the subsystem accessible to be used directly
- You can implement more than one facade for a subsystem