The appearance mode (facade) provides a consistent interface for a set of interfaces in a subsystem that defines a high-level interface that makes this subsystem easier to use.
The appearance pattern perfectly embodies the thought that relies on the reversal principle and the Dimitri rule, so it is one of the more common design patterns.
The appearance mode structure diagram is as follows:
Define three subsystem classes
Public classSubsystemone { Public void MethodOne() {System. out. println ("Subsystem Method 1"); }} Public classSubsystemtwo { Public void Methodtwo() {System. out. println ("Subsystem Method 2"); }} Public classSubsystemthree { Public void Methodthree() {System. out. println ("Subsystem Method 3"); }}
Define a skin facade class
public Class facade {private subsystemone one; private Subsystemtwo; private Subsystemthree three; public facade () {One =new subsystemone (); Two=new subsystemtwo (); Three=new subsystemthree (); } public void MethodA () {one.methodone (); Three.methodthree (); } public void MethodB () {one.methodone (); Two.methodtwo (); }}
Client code
publicstaticvoidmain(String[] args) { Facade facade=new Facade(); facade.methodA(); facade.methodB();}
Due to the role of the facade class, the client can not know the existence of three subsystems at all
Design pattern appearance (facade) mode (note)