话说软件江湖还是混沌之时,无门无派,无招无式,GoF(Gang of Four,四个大师),穷理之熟,融会贯通,合著了《Design Patterns: Elements of Reusable Object-Oriented Software》(即《设计模式》)一书,从此,人人传颂天下武功出少林,设计模式看GoF,这个江湖开始热闹起来了。
……
我们先看设计模式的分类:
范围 | 创建型 | 结构型 | 行为型 |
类 | Factory Method(工厂方法) | Adapter(类) (适配器) | Interpreter(解释器) Template Method(模版方法) |
对象 | Abstract Factory(抽象工厂) Builder(建造者) Prototype(原型) Singleton(单例) | Adapter(对象)(适配器) Bridge(桥接) Composite(组合) Decorator(装饰者) Façade(外观) Flyweight(享元) Proxy(代理) | Chain of Responsibility(职责链) Command(命令) Iterator(迭代器) Mediator(中介者) Memento(备忘录) Observer(观察者) State(状体) Strategy(策略) Visitor(访问者) |
再细点分类:
范围 | 创建型 | 结构型 | 行为型 |
对象创建 | Singleton(单例) Prototype(原型) Factory Method(工厂方法) Abstract Factory(抽象工厂) Builder(建造者) |
|
|
接口适配 |
| Adapter(适配器) Bridge(桥接) Façade(外观) |
|
对象去耦 |
|
| Mediator(中介者) Observer(观察者) |
抽象集合 |
| Composite(组合) | Iterator(迭代器) |
行为扩展 |
| Decorator(装饰)
| Visitor(访问者) Chain of Responsibility(职责链) |
算法封装 |
|
| Template Method(模板方法) Strategy(策略) Command
|
性能与对象访问 |
| Flyweight(享元) Proxy(代理) |
|
对象状态 |
|
| Memento(备忘录) State(状态) |
其它 |
|
| Interpreter(解释器) |
|
|
|
|