设计模式-外观模式
来源:互联网 发布:linux ftp ip地址 编辑:程序博客网 时间:2024/05/22 03:49
1.概念
为子系统中的一组接口提供一个统一接口。Facade模式定义了一个高层接口,这个接口使得这子系统更容易使用。
2.UML
3.代码
下面是一个具体案例的代码:
package facade; class DrawerOne { public void open(){ System.out.println("第一个抽屉被打开了"); getKey(); } public void getKey(){ System.out.println("得到第二个抽屉的钥匙"); } } class DrawerTwo{ public void open(){ System.out.println("第二个抽屉被打开了"); getFile(); } public void getFile(){ System.out.println("得到这个重要文件"); } } class DrawerFacade{ DrawerOne darwerOne=new DrawerOne(); DrawerTwo darwerTwo=new DrawerTwo(); public void open(){ darwerOne.open(); darwerTwo.open(); } } public class DrawerClient{ public static void main(String []args){ DrawerFacade drawer=new DrawerFacade(); drawer.open(); } }
4.应用场景
1)为一个复杂子系统提供一个简单接口。
2)提高子系统的独立性。
3)在层次化结构中,可以使用Facade模式定义系统中每一层的入口。
阅读全文
0 0
- 设计模式--外观模式
- 设计模式-外观模式
- 设计模式:外观模式
- 设计模式----外观模式
- 设计模式------外观模式
- 设计模式 外观模式
- 设计模式-【外观模式】
- 设计模式-----外观模式
- 设计模式 - 外观模式
- 设计模式 - 外观模式
- 设计模式- 外观模式
- 设计模式-外观模式
- 设计模式 - 外观模式
- 设计模式-外观模式
- 设计模式 - 外观模式
- 设计模式-外观模式
- 设计模式--外观模式
- 设计模式-外观模式
- matlab 中K折交叉验证crossvalind函数的理解
- 面试题:HTML语义化的理解
- iOS 控件宽高字体大小适配方法
- SQL索引优化1(索引的概念及技巧)
- AngularJS入门-(3)hello world
- 设计模式-外观模式
- tensorflow object detection 模型测试
- 大数据的75个名词解释
- Install VSFTPD server in Ubuntu 16.04 LTS
- 人和人的差距
- datacleaner第二部分,四、五、六、七章
- C语言sscanf的用法
- 遇到Expected one result (or null) to be returned by selectOne(), but found: 2怎么解决
- 堆栈指针ESP和EBP