Java--设计模式之外观模式
2013-12-16 17:04
489 查看
外观模式,为子系统中的一组接口提供一个一致的界面,此模式定义了一个高层的接口,这个接口似的这一子系统更加容易使用。看例子就明白啦。
1、子系统三个类public class SubSystemOne {
public void methodOne(){
System.out.println("子系统方法一");
}
}
2、外观类
1、子系统三个类public class SubSystemOne {
public void methodOne(){
System.out.println("子系统方法一");
}
}
public class SubSystemTwo { public void methodTwo(){ System.out.println("子系统方法二"); } }
public class SubSystemThree { public void methodThree(){ System.out.println("子系统方法三"); } }
2、外观类
public class Facade { SubSystemOne one; SubSystemTwo two; SubSystemThree three; public Facade(){ one = new SubSystemOne(); two = new SubSystemTwo(); three = new SubSystemThree(); } public void methodA(){ one.methodOne(); two.methodTwo(); three.methodThree(); } public void methodB(){ two.methodTwo(); three.methodThree(); } }3、测试
public class Test { public static void main(String[] args) { Facade facade = new Facade(); System.out.println("方法A"); facade.methodA(); System.out.println("方法B"); facade.methodB(); } }
相关文章推荐
- java设计模式之外观模式(9)
- java软件体系结构设计模式----外观
- JAVA设计模式——外观模式
- java设计模式(十)---外观模式
- Java常用的设计模式12:常用设计模式之外观模式(结构型模式)
- JAVA设计模式之外观模式(Facade)
- java结构型设计模式——外观模式
- Java设计模式之外观模式
- java设计模式之外观模式
- java设计模式(八)---外观模式
- java设计模式---外观模式(facade pattern)
- Java经典设计模式-结构型模式-外观模式(Facade)
- JAVA设计模式初探之——门面模式(外观模式)
- java设计模式之外观模式(门面模式)
- java 设计模式之外观模式的详解(结构模式)
- java/android 设计模式学习笔记(14)---外观模式
- JAVA设计模式之外观模式
- Java设计模式——外观模式
- java设计模式之外观设计模式
- Java设计模式(八) 外观模式详解