Applied Design Patterns with Java
Structural :: Facade (185) {C ch 13}
Collaborations
- Clients communicate with the subsystem by sending requests
to Facade, which forwards them to the appropriate subsystem object(s). Although the subsystem objects
perform the actual work, the Facade may have to do work of its own to translate its interface to subsystem
interfaces.
- Clients that use the Facade don't have to access its subsystem objects directly.
Consequences
The Facade pattern has the following consequences:
- It shields clients from subsystem components, thereby reducing the number of objects that clients deal with and
making the subsystem easier to use.
- It promotes weak coupling between the subsystem and its
clients. Often the components in a subsystem are strongly
coupled. Weak coupling allows varying the components of the subsystem without affecting its clients. Facades help
layer a system and the dependencies between objects. They can eliminate complex or circular dependencies. This
can be an important consequence when the client and the subsystem are implemented independently. Reducing compilation
dependencies is vital in large software systems, saving time by minimizing recompilation when subsystem classes
change. Reducing compilation dependencies with Facades can limit the recompilation needed for a small change in an important
subsystem. A Facade can also simplify porting systems to other platforms, because it's less likely that building
one subsystem requires building all others.
- It doesn't prevent applications from using subsystem classes
if they need to, allowing a choice between ease of use and generality.
Catalog Structural Prev Next