外观模式,为子系统中的一组接口提供一个更一致的界面,定义一个高层接口,这个接口使子系统更加易用. 使用外观类组合子系统的方法调用.
用于将系统业务中不同层次的业务分离,便于维护
import java.util.*;
class SubSystem1 {
public void method1() {
System.out.println(" SubSystem1 method1");
}
}
class SubSystem2 {
public void method2() {
System.out.println(" SubSystem2 method2");
}
}
class SubSystem3 {
public void method3() {
System.out.println(" SubSystem3 method3");
}
}
class Facade {
SubSystem1 one;
SubSystem2 two;
SubSystem3 three;
public Facade() {
one = new SubSystem1();
two = new SubSystem2();
three = new SubSystem3();
}
public void MethodA() {
System.out.println("------A------\n");
one.method1();
two.method2();
}
public void MethodB() {
System.out.println("------B------\n");
two.method2();
three.method3();
}
public static void main(String[] args) {
Facade facade = new Facade();
facade.MethodA();
facade.MethodB();
}
}