设计模式-外观模式(facade pattern)
2015-03-27 14:27
357 查看
名称: 外观模式
说说:电脑启动需要经历哪些环节我不知道,我只需要按下开机按钮
动机:
适用性:
参与者:
结果:将一套行为封装到一个方法中,即定义一个高层接口,用来访问子系统中的一群接口
类图:
说明:简化了客户与子系统的交互过程,降低了客户与子系统的耦合度
demo c#:
说说:电脑启动需要经历哪些环节我不知道,我只需要按下开机按钮
动机:
适用性:
参与者:
结果:将一套行为封装到一个方法中,即定义一个高层接口,用来访问子系统中的一群接口
类图:
说明:简化了客户与子系统的交互过程,降低了客户与子系统的耦合度
demo c#:
namespace facade { class Program { static void Main(string[] args) { var _tv = new tv(); var _light = new light(); var _other = new otherEquipment(); var power = new Power(_tv, _light, _other); power.powerOff(); Console.Read(); } } class tv { public void powerOff() { Console.WriteLine("tv is turn off"); } } class light { public void lightOff() { Console.WriteLine("light is turn off"); } } class otherEquipment { public void allClose() { Console.WriteLine("all Electric equipment closed!"); } } class Power { tv _t; light _l; otherEquipment _o; public Power(tv t, light l, otherEquipment o) { this._t = t; this._l = l; this._o = o; } // 统一的高层接口,控制一群子系统对象 public void powerOff(){ this._t.powerOff(); this._l.lightOff(); this._o.allClose(); } } }
相关文章推荐
- 解读设计模式----外观模式(Facade Pattern),谈阿牛讨媳妇故事
- 十三.结构型设计模式——Facade Pattern(外观模式)
- C#设计模式——外观模式(Facade Pattern)
- 我所理解的设计模式(C++实现)——外观模式(Facade Pattern)
- 设计模式 - Facade Pattern(外观模式)
- 设计模式――外观模式(Facade Pattern)
- [译]The Facade Pattern外观设计模式 from Chapter 6 of《Design Patterns Explained》
- 23种设计模式-9.外观模式(Facade Pattern)
- 乐在其中设计模式(C#) - 外观模式(Facade Pattern)
- 设计模式笔记10:外观模式(Facade Pattern)
- 我读设计模式之外观模式(Facade Pattern)
- 设计模式 - Facade Pattern(外观模式)
- 设计模式笔记10:外观模式(Facade Pattern)
- 极速理解设计模式系列:13.外观模式(Facade Pattern)
- 设计模式学习总结-外观模式(Facade Pattern)
- 设计模式-外观模式(Facade Pattern)
- Php设计模式之【外观模式Facade Pattern】
- 解读设计模式----外观模式(Facade Pattern),谈阿牛讨媳妇故事
- 设计模式——外观模式(FacadePattern)
- 深入浅出设计模式-008:外观模式(Facade Pattern)