The Facade pattern simplifies access to a related set of objects by providing one object that all objects outside the set use to communicate with the set.
Often you will have many classes that, together, perform related functions. An example is a set of classes that collaborate to format and sent e-mail messages. Depending upon the number of classes, it may be quite difficult to understand the essential interface to performing specific tasks. A facade pattern can help reduce the complexity by only presenting the essential interface to a set of classes through an object.
Create a class that calls the methods in the real objects. The client interacts with an instance of this class rather than the set of classes that it hides.
Because the Facade pattern hides other objects, the client is simplified because it doesn't have to know about the other classes. This reduces the coupling between client classes and the clases it uses. Clients can still access the objects behind the Facade if necessary.
Some classes / objects behind the Facade may be ones that never should be visible to the client, but are necessary for the operations to take place. The Facade can completely hide these by making them private inner classes to the Facade class.
Interface
Modified:
12-Feb-2004
Gary Pollice