Design pattern learning I: Facade pattern

原创 2006年05月27日 02:01:00

Gang of Four says: Provide a unified interface to a set of interfaces in subsystem. Facade defines a higher-level interface that makes the subsystem easier to use.

Facade pattern enables us to use a complex system more easily, either to use just a subset of the system in a particular way.

Facade can be used not only to create a simpler interface in terms of method calls, but also reduce the number of objects that a client object must deal with.

Facade pattern applies when:
1. You don't need to use all of the functionality of a complex system and can create a new class that contains all of the rules for accessing that system.
2. You want to encapsulate or hide the orignial system.
3. You want to use the functionality of the original system and want to add some new functionality as well.
4. The cost of writing this new class is less than the cost of everybody learning how to use the original system or is less then you would spend on maintenance in the future.


GOF说:
Facade模式在子系统的接口集上提供了统一的对外接口。Facade定义了一个高层的接口使得子系统更容易被使用。

定义:
Facade模式使得我们更容易使用一个复杂系统,或者通过特殊方式使用系统的一个子集。它不仅能用来创建一个简单的接口,也减少了客户必须交互的对象数量。

可以把Facade应用在:
1. 你不想使用复杂系统的所有功能,并创建一个新的类来包含所有的访问系统的规则
2. 你想封装或者隐藏原系统
3. 你想使用原系统的功能,也想添加新的功能
4. 学习或维护原系统的代价要比创建新的接口类大

相关文章推荐

java design pattern -- facade

Facade外观模式(门面模式):  为子系统中的一组接口提供一个统一接口。Facade模式定义了一个更高层的接口,使子系统更加容易使用。  Facade模式是为了降低子系统之间,客户端与实现化层...

Facade Design Pattern

Provide a unified interface to a set of interfaces in a subsystem. Facade Pattern defines a higher-l...

Design Pattern Explained 读书笔记三——Facade

what? Provide a unified interface to a set of interfaces in a sub- system. Facade defines a hig...
  • lemon89
  • lemon89
  • 2015年07月14日 22:27
  • 1610

Head First 设计模式 Design Pattern 7-8 Adapter & Facade, Template Method

Section 7 适配器模式和外观模式 Adapter & Facade >客户使用适配器 Client - Request -> Adapter -> TranslateRequest - A...

When should I use the Visitor Design Pattern?

I keep seeing references to the visitor pattern in blogs but I’ve got to admit, I just don’t get it....

Design Pattern学习笔记之适配和外观(the Adapter and Facade Pattern)

Design Pattern学习笔记之适配和外观(the Adapter and Facade Pattern) 1.    引子--Whois? a.      应用适配器模式可实现你想不到的伟...

Design Pattern - Structural Patterns - Facade Pattern

2007 Section 5, Chapter 4 Facade Pattern Concept A Facade patter...

又一种design pattern —— 局部整体化设计模式

0.简介             什么是局部整体化呢?简单来说,就是把组成大部件的零件也当成大部件来看待,这样的话,一个大部件实际上就是由很多大部件(逻辑上是小零件)来构建而成的。听起来是挺怪的,至...

Java设计模式中单例模式(Design Pattern):懒汉模式和饿汉模式

设计模式,是被反复使用,多数人知道,并经过分类的代码设计经验的总结。目的自然是代码的重用,理解,可靠等。 所谓单例模式,就是有些对象只需要一个,比如,配置文件,工具类,线程池,缓存,日志对象等等,在...

Interaction design pattern

Interaction design is the art of facilitating interactions between humans through products and servi...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Design pattern learning I: Facade pattern
举报原因:
原因补充:

(最多只允许输入30个字)