设计模式

设计模式介绍

可复用面向对象软件的基础

设计模式分类

<> 归纳23种设计模式

  • 创建型
  • 结构型
  • 行为型

创建型模型

  • 工厂方法模式(Factory Method)
  • 抽象工厂模式(Abstract Factory)
  • 创建者模式(Builder)
  • 原形模式(Prototype)
  • 单例模式(Singleton)

结构型模型

  • 外观模式(Facade)
  • 适配器模式(Adapter)
  • 代理模式(Proxy)
  • 装饰模式(Decorator)
  • 桥模式(Bridge)
  • 组合模式(Composite)
  • 享元模式(Flyweight)

行为模式

  • 模板方法模式(Template Method)
  • 观察者模式(Observer)
  • 状态模式(State)
  • 策略模式(Strategy)
  • 职责链模式(Chain of Responsibility)
  • 命令模式(Command)
  • 访问者模式(Visitor)
  • 调停模式(Mediator)
  • 备忘录模式(Memento)
  • 迭代器模式(Iterator)
  • 解释器模式(Interpreter)

设计模式六大原则

  1. 开闭原则(Open Close Principle)
  2. 里氏代换原则(Liskov Substitution Principle)
  3. 依赖倒转原则(Dependence Inversion Principle)
  4. 接口隔离原则(Interface Segregation Principle)
  5. 迪米特法则(最少知道原则)(Demeter Principle)
  6. 合成复用原则(Composite Reuse Principle)