Facade pattern
- Provide access to the outside world for a complex of a module or subsystem interface
- Subsystems are relatively independent, external access to the subsystem can operate as long as the black box
- By providing a consistent interface to multiple complex subsystems, subsystems which the pattern to be accessed more easily
Appearance (Facade) role : to provide a common multiple of external interface subsystem.
Subsystem (Sub System) role : to achieve part of the system functions, customers can access it through the appearance of the characters.
Customer (Client) Role : access by various subsystems of the appearance of a role.
1 public class Facade { 2 public static void main(String[] args) { 3 new total().methods(); 4 } 5 } 6 7 //外观角色 8 class total { 9 private one one = new one(); 10 private two two = new two(); 11 private three three = new three(); 12 13 public void methods() { 14 one.method1(); 15 two.method2(); 16 three.method3(); 17 } 18 } 19 20 //子系统 21 class two { 22 public void method2() { 23 System.out.println("方法1"); 24 } 25 } 26 27 class three { 28 public void method3() { 29 System.out.println("方法2"); 30 } 31 } 32 33 class one { 34 public void method1() { 35 System.out.println("方法3"); 36 } 37 }