Purpose |
- Provide a simple interface to a complex system. By implementing
the simpler interface in terms of the backend interface[s], the facade adds
value.
- Decouple backend API from the client API. This is useful when
backend API is not sufficiently stable to use as a client API.
- Realize a layer's API. Consolidate a collection of class's APIs,
hiding the class structure from the client.
An articulation point allows 1 endpoint to move (i.e., interface to change)
without forcing another endpoint to move. For example, your elbow is an articulation
point; it allows you to move your hand without moving your upper arm.
This facade is used (as an adaptor or bridge) when:
- A client is controlling an object B
- B's interface may change
- we want to hide these changes from B's clients.
The solution is to interpose an articulation point A: a class that presents
a stable interface to clients, but which translates a client's requests to
control B into B's [possibly unstable] interface.
Jini example: we may want to decouple a service's client interface
from the service's proxy interface.
|
Structure |
|
Consequences |
The articulation point is an extra class. If B's interface is stable
& simple, then A is extra baggage. |
Implementation |
- From the client's standpoint, the backend API is private. Declarations
enforce this. For example, put the facade and backend classes in a separate
package from the client, making the backend API package-private, but the
facade API public (or at least accessible to the clients).
|
Sample Code |
|
Related Patterns |
Bridge, Adaptor
|