外观模式
外观(Facade)模式又叫作门面模式,是一种通过为多个复杂的子系统提供一个一致的接口,而使这些子系统更加容易被访问的模式。
java
public class Police {
public void resgister(String name){
System.out.println("公安系统注册:"+name);
}
}
java
public class School {
public void assignSchool(String name){
System.out.println(name+"学校报道");
}
}
java
public class Social {
public void handleSocial(String name){
System.out.println("社保关系已转移");
}
}
将以上三个部门组合成一个门面:
java
public class WeiXinFacade {
Police police = new Police();
School school = new School();
Social social = new Social();
public void handleAll(String name){
police.resgister(name);
school.assignSchool(name);
social.handleSocial(name);
}
}
也可为每一个部门单独提供方法