Design-pattern

介绍

以图解设计模式 ([日]结城浩) 为主线做的笔记

注意

作者在书中强调了"不要使用具体类来编程,要优先使用抽象类和接口来编程"。

我虽然没有达到作者的那种境界,但是对这句话存在十分敬畏。

结构

  1. 适应设计模式
    1. Iterator模式
    2. Adapter模式
  2. 交给子类
    1. Template Method模式
    2. Factory Method模式
  3. 生成实例
    1. Singleton模式
    2. Prototype模式
    3. Builder模式
    4. Abstract Factory模式
  4. 分开考虑
    1. Bridge模式
    2. Strategy模式
  5. 一致性
    1. Composite模式
    2. Decorator模式
  6. 访问数据结构
    1. Vistor模式
    2. Chain_of_Resposibility模式(责任链)
  7. 简单化
    1. Facade模式(外观窗口)
    2. Mediator模式(调节者)
  8. 管理状态
    1. Observer模式(观察者)
    2. Memento模式(纪念品,保存对象状态)
    3. State模式(用类表示状态)
  9. 避免浪费
    1. Flyweight模式(共享对象)
    2. Proxy模式(代理)
  10. 用类来表现
    1. Command模式
    2. Interpreter模式(解释,语法)

GoF对设计模式的分类

  1. 创建型设计模式
    1. Abstract Factory
    2. Builder
    3. Factory Method
    4. Prototype
    5. Singleton
  2. 结构型设计模式
    1. Adapter
    2. Bridge
    3. Composite
    4. Decorator
    5. Facade
    6. Flyweight
    7. Proxy
  3. 行为型设计模式
    1. Chain of Responsibility
    2. Interpreter
    3. command
    4. Iterator
    5. Mediator
    6. Memento
    7. Observer
    8. State
    9. Strategy
    10. Template Method
    11. Vistor

目前还没有搞懂它们分类的依据以及区别。

引用

[1] 参考代码地址

[2] 更详细的文档