Facade
Definition
Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use.
Class Diagram
Participants
-
Facade.
- knows which subsystem classes are responsible for a request.
- delegates client requests to appropriate subsystem objects.
-
Subsystem classes.
- implement subsystem functionality.
- handle work assigned by the Facade object
- have no knowledge of the facade and keep no reference to it.
Benefits
- Provides a simple interface to a complex system without reducing the functionality provided by the system.
- Shields clients from complexity of subsystem components.
- Promotes weak coupling between the subsystem and its clients.
- Reduces coupling between subsystems if every subsystem uses its own facade pattern.
- Translates client requests to the subsystems that can fulfill those requests.
Usage
- When you want to provide a simple interface to a complex subsystem.
- When there are many dependencies between clients and the implementation classes of an abstraction.
- When you want to layer your subsystems.