package facade_pattern;
public class SubSystemOne {
public void Method() {
System.out.print("The system one.");
}
}
package facade_pattern;
public class SubSystemTwo {
public void Method() {
System.out.print("The system two.");
}
}
package facade_pattern;
public class SubSystemThree {
public void Method() {
System.out.print("The system three.");
}
}
package facade_pattern;
public class SubSystemFour {
public void Method() {
System.out.print("The system four.");
}
}
package facade_pattern;
public class Facade {
SubSystemOne one;
SubSystemTwo two;
SubSystemThree three;
SubSystemFour four;
public Facade() {
one = new SubSystemOne();
two = new SubSystemTwo();
three = new SubSystemThree();
four = new SubSystemFour();
}
public void MethodA() {
System.out.println("The method A:");
one.Method();
two.Method();
four.Method();
}
public void MethodB() {
System.out.println("The method B:");
one.Method();
three.Method();
four.Method();
}
}
package facade_pattern;
public class Main {
public static void main(String args[]) {
Facade facade = new Facade();
facade.MethodA();
facade.MethodB();
}
}
/*
*The facade_pattern likes a facade that is used to communicate with outside.
*Through this method we can provide the simple interface for those complicated
*subsystem so as to reduce coupling.This is also a client's simplification.
*The other situation using facade_pattern is when we have to reserve the old
*and disordered system's functions for constructing new system,which can be
*seen as the new facade for interacting.
*/
This is a general introduction to the 23 design patterns in chinese:
https://blog.csdn.net/GZHarryAnonymous/article/details/81567214
See more source code:[GZHarryAnonymous](https://github.com/GZHarryAnonymous/Design_Pattern)