Livin' Virtual World

Game develop, Programming & Fun

Design pattern learning I: Facade pattern

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.



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

上一篇Dead Reckoning: 在网络游戏中消除延时影响
下一篇Design pattern learning II: Adapter pattern
想对作者说点什么? 我来说一句

GOF设计模式中文版(Design Pattern

2011年04月10日 10.11MB 下载


2016年09月24日 45.97MB 下载