Please enable JavaScript.
Coggle requires JavaScript to display documents.
Facade (Applicability (Facade helps to decouple the client from the…
Facade
Applicability
-
-
Subsystems lead to smaller classes that lend themselves to reuse and customization. But if a client does not want to customize, use a facade to provide the required functionality to client by gluing these classes
Consequences
Promotes weak coupling between client and subsystems allowing you to vary components of subsystem without affecting the client
-
Shields clients from subsystems, reducing the number of objects that the client deals with
Motivation
To reduce complexity we break down a system into subsystems. However this increases the communication and dependencies between subsystems. One way to reduce this is to introduce a facade object that provides a single, simplified interface to the more general facilities of a subsystem
-
Key Objects
-
Subsystem classes - implement subsystem functionality and handle work assigned by facade. They do not maintain a reference to the facade
Implementation
Reducing client-subsystem coupling - Facade can be made into an abstract class with concrete subclasses to implement different subsystem functionality. Client can interact with subsystems through the interface of the abstract class
Public vc Private subsystem classes - If system allows it, segregate the subsystem classes into public and private classes. Public classes are available to client in addition to the facade, private classes are not
Applications
-
In a UI framework have presentation classes responsible for the UI while the application facade talks to domain model and give the presentation classes data in a format that they can use
Intent
Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes a subsystem easier to use
-