Facade Mode
The facade mode requires that the external communication between a sub-system and its internal systems must be performed through a unified facade object. The facade mode provides a high-level interface to make subsystems easier to use.
Just like the Hospital Receptionist, the facade class in the facade mode separates the internal complexity of the client from the subsystem, so that the client only needs to deal with the facade object, instead of dealing with many objects in the subsystem.
Structure of observer Mode
FacadeKey Points
From the perspective of the customer program, the facade mode not only simplifies the interface of the entire component system, but also for the internal and external customer program of the component, to some extent, it achieves a "decoupling" effect-any changes to the internal subsystem will not affect the changes to the fa c Ade interface.
The fa c ade design model focuses more on the entire system from the architectural level, rather than the individual class level. Fa C Ade is often an architectural design model.
The fa c ade design pattern is not a container and can be put into any number of objects at will. In the fa c Ade mode, components should be "a series of components with relatively large Coupling Relationships", rather than a simple set of functions.
Note
Fa C Ade mode, adapter mode, bridge mode, and decorator mode. The FA-ade mode focuses on simplified interfaces, the adapter mode focuses on the conversion interfaces, and the bridge mode focuses on the separation of interfaces (abstraction) and their implementation. The decorator mode focuses on the object extension function on the premise of a stable interface.
Applicability
1. provides a simple interface for a complex subsystem.
2. Improve the independence of subsystems.
3. In a hierarchical structure, you can use the facade mode to define the entries for each layer of the system.
Facade mode Model
A systems include A1, A2, and A3. The client needs to call a1.dosomething1 (), a2.dosomething2 (), and a3.dosomething3 () of system A to complete a function.
The implementation model of the facade mode is:
System:
Class A1 {
Public void dosomething1 ();
}
Class A2 {
Public void dosomething2 ();
}
Class A3 {
Public void dosomething3 ();
}
Facade:
Public class facade {
Public void dosomething (){
A1 a1 = new A1 ();
A1 a2 = new A2 ();
A1 a3 = new A3 ();
A1.dosomething1 ();
A2.dosomething2 ();
A3.dosomething3 ();
}
}
Test:
Public class client {
Public static void main (string [] ARGs ){
Facade facade = new facade ();
Facade. dosomething ();
}
}
Facade Design Mode