Definition
Provide a unified interface to a set of interfaces in a subsystem. Façade defines a higher-level interface that makes the subsystem easier to use.
UML Class Diagram
Façade: when and where use it
- A Façade is a class that provides an interface (a set of methods and properties) that makes it easier for clients to use classes and objects in a complex subsystem. The Façade pattern is a simple pattern and may seem trivial. Yet, its influence are far-reaching as it is one of the most commonly used design patterns in systems that are built around a 3-tier architectural model.
- The intent of the Façade is to provide a high-level architectural interface that makes a subsystem or toolkit easy to use for the client. In a 3-tier application the presentation layer is the client. Calls into the business layer take place via a well defined service layer. This service layer, or façade, hides the complexity of the business objects and their interactions.
- Another area where you use Façade patterns is in refactoring efforts. If you?re dealing with a confusing or messy set of legacy classes that the client programmer should not see you hide it behind a Façade. The Façade exposes only what is necessary for the client and presents it in an easy to use and well-organized interface.
- Façades are frequently combined with other design patterns. Facades themselves are often implemented as singleton abstract factories. However, you can get the same effect by using static methods on the Façade.
Sample
- Sub-system business
- Facade class
- Client
Ref: Gang of Four tutorial
No comments:
Post a Comment