Façade Pattern
Summary
- The role of the Façade pattern is to provide different high-level views of subsystems whose details are hidden from users.
- The Façade pattern is used to reorganize a system with many subsystems into identifiable layers with single entry points. Essentially,
simplifies the interface to a complex subsystem.
- The Façade pattern can be used to make frequent use of a system faster, or to differentiate between novices and power users.
- Everything in the façade has to be public so that the Client, which is compiled into a different assembly, can access it.
The classes all have the default internal visibility, limiting access to them to the assembly in which they were compiled (excluding
the Client).
- The Façade pattern uses the C# concept of namespaces.
Alternative implementations of the Façade pattern
Transparent Façades
- Change all the internal modifiers to public, which will make the façade optional, or transparent.
- That is, as well as being able to go through the Façade, the client will be able to instantiate System classes directly.
Static Façades
- This implies that façade is a static class.
- No instantiation is necessary; the user interfaces with the façade class directly.
Class diagram: (see Façade Pattern code review)
Usage
Use the Façade pattern when:
- Subsystem operations can only be called through the Façade.
- Subsystem operations can be called directly as well as through the Façade.