外观模式 (Facade)
为子系统中的一组接口提供一个一致的界面,此模式定义了一个高层接口,这个接口使得这一子系统更加容易使用。
外观模式是一种结构型模式。
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfkAAAF4CAIAAADYOBfOAAAgAElEQVR4nO3de1wU9eL/8TUTPeIlL6h1NH2I6TE9eazINDpn8ULnpJUdxWOipB7ytuBPzGsQdwQSSWGVkFRQhHqgeYEUJN0KL4iKpiWiogihyU1BEJbb/P6Yw3zH3WUdYD8zO599P/+CYXf2MzM7r2z4MKtgAACAdgqpBwAAAMSh9QAA9EPrAQDoh9YDANAPrQcAoB9aDwBAP7QeAIB+aD0AAP3QegAA+qH1AAD0Q+sBAOiH1gMA0A+tB9PYv3//2yDY/v37pT5iYFnQejANtVo9fPjwKBBg+PDharVa6iMGlgWtB9NQq9VKpVLqUciDUqlE60FkaD2YBlovHFoP4kPrwTTQeuHQehAfWg+mgdYLh9aD+BQMwyxfvlzqWQlgAuHh4RK+k9B64dB6EJ9i8eLFL7zwggLkb9SoUWFhYVK9k9B64dB6EN//MqFUKpeDnL3yyivscZTqnSR+6x8/frx9+/YtW7b88ssvYr5u+6H1IL7/tR7vPLlTqVQUt768vDz9SefPny8uLraxseHevdxjysvL2/xChYWF6enpP/30k1arNd3wdaH1ID60nhIUt766unrfvn3PPPNM//79n2/23nvvXblypU+fPty799SpU+yPTp061ebXUqvVCoXCxsamuLjYdFugC60H8aH1lKC49TExMd27d+/bt+/169fLmx05cuS5557r0KED9+6tr69nf1RfX9/m10LrgVZoPSUobr3B/mo0Gu6X0uy7Nzs7297e3t7ePjs7m2GY/fv32/Ow95/hP2bTpk3s19OmTXvw4AHDMJs2bbK1tVUoFJ06dRo3bhz3LJND60F8aD0lLK31d+/eDQsL6969O/fu5eqv0Wj27t371ltvjRgxIjo6Ojo6evjw4W+99dbevXu5x0ybNi0wMDA6OvrTTz/t0qWLi4tLbm7uyZMn58yZo1AounfvHhYWFh0d/euvv5LYIrQexIfWU8LSWs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oB9aDwBAP7QeAIB+aD0AAP3QegAA+qH1AAD0Q+sBAOiH1gMA0A+tBwCgH1oPAEA/tB4AgH5oPQAA/dB6AAD6ofUAAPRD6wEA6IfWAwDQ7ymt9/Dw+AkAAGTu0KFDzz33XIutBwAAmqD1AAD00239CQAAoM7vv//+ROtN/YsBAAAwO2g9AAD90HoAAPqh9QAA9EPrAQDoh9YDANAPrQcAoN//ByuqpqnZkYnZAAAAAElFTkSuQmCC" alt="" />
图-外观模式结构图
Facade : 了解每个子系统类的功能,负责分发客户端的请求给各个子系统去处理。
class Class1 {
public void op1() {
System.out.println("方法1");
}
}
class Class2 {
public void op2() {
System.out.println("方法2");
}
}
class Class3 {
public void op3() {
System.out.println("方法3");
}
}
Subsystem Classes : 实现子系统功能。在不感知 Facade 的情况下,处理 Facade 对象分配的工作,
class Facade {
private Class1 one = new Class1();
private Class2 two = new Class2();
private Class3 three = new Class3();
public void op1() {
System.out.println("Facade op1()");
one.op1();
}
public void op2() {
System.out.println("Facade op2()");
two.op2();
}
public void op3() {
System.out.println("Facade op3()");
three.op3();
}
public void Method() {
System.out.println("Facade Method()");
three.op3();
two.op2();
one.op1();
}
}
测试代码
public class FacadePattern {
public static void main(String[] args) {
Facade facade = new Facade();
facade.Method();
facade.op1();
}
}
运行结果
Facade Method()
方法3
方法2
方法1
Facade op1()
方法1
1、外观模式为复杂子系统提供了一个简单接口,并不为子系统添加新的功能和行为。
2、外观模式实现了子系统与客户之间的松耦合关系。
3、外观模式没有封装子系统的类,只是提供了简单的接口。 如果应用需要,它并不限制客户使用子系统类。因此可以再系统易用性与通用性之间选择。
4、外观模式注重的是简化接口,它更多的时候是从架构的层次去看整个系统,而并非单个类的层次。
推荐
本文属于 JAVA设计模式系列 。
参考资料
《大话设计模式》
《HeadFirst设计模式》
- Java设计模式——外观模式
JAVA 设计模式 外观模式 用途 外观模式 (Facade) 为子系统中的一组接口提供一个一致的界面,此模式定义了一个高层接口,这个接口使得这一子系统更加容易使用. 外观模式是一种结构型模式. 结构
- 【设计模式】Java设计模式 - 外观模式
Java设计模式 - 外观模式 不断学习才是王道 继续踏上学习之路,学之分享笔记 总有一天我也能像各位大佬一样 原创作品,更多关注我CSDN: 一个有梦有戏的人 准备将博客园.CSDN一起记录分享自己 ...
- java设计模式——外观模式(门面模式)
一. 定义与类型 定义:门面模式,提供一个统一的接口,用来访问子系统中的一群接口,门面模式定义了一个高层接口,让子系统更容易使用 类型:结构性 二. 使用场景 子系统越来越复杂,增加外观模式提供简单调 ...
- Java设计模式---外观模式
外观模式(Facade) 外观模式的意图是:为子系统提供一个接口,便于它的使用. 解释: 简单的说,外观模式就是封装多个上层应用需要的方法,使得上层调用变得简单,为上层提供简单的接口,是设计模式中 ...
- Java设计模式-外观模式(Facade)
外观模式是为了解决类与类之家的依赖关系的,像spring一样,可以将类和类之间的关系配置到配置文件中,而外观模式就是将他们的关系放在一个Facade类中,降低了类类之间的耦合度,该模式中没有涉及到接口 ...
- 菜鸟版JAVA设计模式—外观模式
外观模式是一种比較easy理解的模式,作用非常easy.就是解耦合. 结构也是非常easy,一个外观类.这个外观类持有非常多的业务类. 再由客户类去调用这个外观类去实现一些列的业务操作... 这个模式 ...
- java设计模式----外观模式(门面模式)
外观模式主要应用场景在于为复杂的子系统提供一个简单的接口,提高子系统的独立性. 创建DrawerOne类: package facade; public class DrawerOne { publi ...
- Java设计模式——组合模式
JAVA 设计模式 组合模式 用途 组合模式 (Component) 将对象组合成树形结构以表示“部分-整体”的层次结构.组合模式使得用户对单个对象和组合对象的使用具有唯一性. 组合模式是一种结构型模 ...
- java设计模式--单列模式
java设计模式--单列模式 单列模式定义:确保一个类只有一个实例,并提供一个全局访问点. 下面是几种实现单列模式的Demo,每个Demo都有自己的优缺点: Demo1: /** * 单列模式需要满足 ...
随机推荐
- 2016,Raym
Hello,2016: 这是承上启下的一年! Raym
- SQLSERVER中如何忽略索引提示
SQLSERVER中如何忽略索引提示 当我们想让某条查询语句利用某个索引的时候,我们一般会在查询语句里加索引提示,就像这样 当在生产环境里面,由于这个索引提示的原因,优化器一般不会再去考虑其他的索引, ...
- CodeIgniter2.2.0-在控制器里调用load失败报错的问题
报错如下: hello A PHP Error was encountered Severity: Notice Message: Undefined property: Test::$load Fi ...
- 轻量级MVC框架:Nancy学习
一.认识Nancy 今天听讲关于Nancy框架的培训,被Nancy的易用性所吸引.故晚上回来梳理了一下知识. 什么是Nancy呢?如标题所述,Nancy是一个轻量级的独立的框架: Nancy 是一个轻 ...
- 设计模式之美:Interpreter(解释器)
索引 意图 结构 参与者 适用性 效果 相关模式 实现 实现方式(一):Interpreter 模式结构样式代码. 实现方式(二):解释波兰表达式(Polish Notation). 意图 给定一个语 ...
- 案例研究:Web应用间歇性SqlException
最近有客户找到我,说他们生产环境的事件日志中有下面的报错.要我帮忙找找原因. Event Type: Warning Event Source: ASP.NET 2.0.50727.0 Event C ...
- 支持断点续传的文件上传插件——Huploadify-V2.0来了
之前仿造uploadify写了一个HTML5版的文件上传插件,没看过的朋友可以点此先看一下~得到了不少朋友的好评,我自己也用在了项目中,不论是用户头像上传,还是各种媒体文件的上传,以及各种个性的业务需 ...
- C#Light/Evil合体啦
决定将C#Light和C#Evil合并成一个项目,毕竟C#Evil包含C#Light所有的功能,分开两个,基本的表达式方面有什么bug还得两头改 暂时就C#Light/Evil这么叫吧,庆祝合体,画了 ...
- ASP.NET集成模式下的管道事件
- linux环境 c 中如何执行shell命令
1 system 相当简单: int system(const char *command); system("ps -aux"); 2 popen popen有两个参数,第一个是 ...