The problem with the above a solution is that the component customers and various complex subsystems in the component have too many coupling, as external customersProgramWith the evolution of various subsystems, this excessive coupling is faced with many changing challenges.
How to simplify the interaction interfaces between external client programs and systems? How can we decouple the dependency between the evolution of external customer programs and the changes of internal subsystems?
Intention:
Provides a consistent interface for a group of interfaces in the subsystem. The Fa-ade mode defines a high-level interface, which makes the subsystem easier to use.
Using System;
Internal Class Wheel
{
Public Void Waction1 (){}
Public Void Waction2 (){}
}
Internal Class Engine
{
Public Void Eaction1 (){}
Public Void Eaction2 (){}
}
Internal Class Bodywork
{
Public Void Baction1 (){}
Public Void Baction2 (){}
}
Internal Class Controller
{
Public Void Caction1 (){}
Public Void Caction2 (){}
}
Public Class Tankfacade
{
Wheel [] Wheels = New Wheel [ 4 ];
Engine [] Engines = New Engine [ 4 ];
Bodywork bodywork = New Bodywork ();
Controller = New Controller ();
Public Void Start (){}
Public Void Stop (){}
Public Void Run (){}
Public Void Shot (){}
}
Key points:
1. 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 programs 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;
2. Fa C The ade design pattern is not a container and can be put into any number of objects. In the facade mode, components should be "a series of components with relatively large Coupling Relationships", rather than a simple set of functions;
3. Differentiate the facade mode, adapter mode, bridge mode, and decorator mode.
Facade mode focuses on simplified Interfaces,
Adapter mode focuses on the conversion interface,
Bridge Mode focuses on separating interfaces (abstraction) and Its Implementation,
The decorator mode focuses on stable interfaces and extends the object functions..
Applicability:
1. Provide 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.