Java Reference
In-Depth Information
Figure 3.7. Facade object diagram
Implement the following for Facade:
Facade - The class for clients to use. It knows about the subsystems it uses and their respective responsibilities.
Normally all client requests will be delegated to the appropriate subsystems.
Subsystem - This is a set of classes. They can be used by clients directly or will do work assigned to them by
the Facade. It does not have knowledge of the Facade; for the subsystem the Facade will be just another client.
Benefits and Drawbacks
The benefit of the Facade pattern is that it provides a simple interface to a complex system without reducing the
options provided by the total system. This interface protects the client from an overabundance of options.
The Facade translates the client requests to the subsystems that can fulfill those requests. Most of the time, one
request will be delegated to more than one subsystem. Because the client interacts only with the Facade, the
internal working of the system can change, while the client to the Facade can remain unchanged.
The Facade promotes low coupling between client and subsystems. It can also be used to reduce coupling
between subsystems. Every subsystem can have its own Facade and other parts of the system use the Facade to
communicate with the subsystem.
Pattern Variants
Pattern variants include the following:
You can implement the Facade as an interface or an abstract class. This leaves the implementation details to a
later time. It also reduces coupling.
Several Facades can provide different interfaces to the same set of subsystems.
The Facade pattern is sometimes varied in order to hide the subsystems. When the Facade pattern is used at the
boundary between systems in an architecture, one of its goals is to reduce the complexity of system-system
interaction. For instance, a system where calls pass through a central facade is more maintainable than one with a
large number of cross-coupled classes).
Related Patterns
Related patterns include the following:
 
Search WWH ::




Custom Search