background
A tank system, subsystems are crawler systems, engine systems, artillery systems, defense armor systems and so on. External interface is the exposure to the user is run (), shot (), stop () and so on. If the facade mode is not used, the starting tank needs to be directly dependent on the crawler system, engine system. To operate the track directly and operate the engine? Each interface and subsystem has a tight coupling. (quoted from the Internet)
The problem arises: there is too much coupling between the client (interface) of the component and the complex subsystems within the component, and this coupling faces the challenge of change as the external client program and each subsystem change.
How to simplify the interface between external client program and system , how to decouple the evolution of external program and the change of internal subsystem?
Make it simple and simple! No matter how the internal implementation changes, we just run (), shot (), Stop ()!
1. Intention to use
providing a consistent interface for a set of interfaces in a subsystem, the facade schema defines a high-level interface that makes this subsystem easier to use .
2. Life Example
The appearance mode defines a unified, higher-level interface for the interface in the subsystem for easy use . When the consumer calls the order, it embodies a look mode. The customer calls a number to contact the customer service representative, who plays the "look", which includes an interface with the ordering department, the cashier's department and the delivery department.
3. Java Example (framework, JDK, JEE)
Tika,apache a text content grab frame, TIka in the TIka class uses the appearance mode, this class mainly integrates the language recognition, the content parsing, the type recognition, TIka class through the appearance mode to unify the function of the above several classes to come out, namely the parser method, Within the parser method, call these small modules yourself to complete the function!
4. Pattern class Diagram
5. Advantages of the Model
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 pattern to define the entry for each layer in the system.
6. Comparison with similar models
1, facade design mode more attention from the architecture level to look at the entire system, rather than the level of a single class. Facade is often more of an architectural design pattern.
2, facade more attention to simplify the interface, adapter mode focus on the conversion interface, bridge mode focus on separation Interface (abstraction) and its implementation, decorator mode focus on the premise of stable interface for the object expansion function.
The design pattern of the vegetable--appearance mode