# 门面模式
# 简介
结构型模式,也叫外观模式,封装复杂子系统或流程,对外提供一个方便调用的统一api,屏蔽子系统/流程细节。
# 示例
public class SubSystem_A {
public void doSomeThing(){
System.out.println("SubSystem_A do some thing!");
}
}
public class SubSystem_B {
public void doSomeThing(){
System.out.println("SubSystem_B do some thing!");
}
}
public class SubSystem_C {
public void doSomeThing(){
System.out.println("SubSystem_C do some thing!");
}
}
public class Facade {
private SubSystem_A subSystem_a = new SubSystem_A();
private SubSystem_B subSystem_b = new SubSystem_B();
private SubSystem_C subSystem_c = new SubSystem_C();
public void doSomeThing_A() {
subSystem_a.doSomeThing();
}
public void doSomeThing_B() {
subSystem_b.doSomeThing();
}
public void doSomeThing_C() {
subSystem_c.doSomeThing();
}
public void allDoSomeThing() {
subSystem_a.doSomeThing();
subSystem_b.doSomeThing();
subSystem_c.doSomeThing();
}
}
# 调用
@Test
public void tt(){
Facade facade = new Facade();
facade.doSomeThing_A();
facade.doSomeThing_B();
facade.doSomeThing_C();
facade.allDoSomeThing();
}