设计模式概述

"设计模式"总的来说有设计原则6个,设计模式3类23种:

6个设计原则

  • 单一职责原则(Single Responsibility Principle, SRP)
  • 开闭原则(Open Close Principle, OCP)
  • 里氏替换原则(Liskov Substitution Principle, LSP)
  • 依赖倒转原则(Dependence Inversion Principle, DIP)
  • 接口隔离原则(Interface Segregation Principle, ISP)
  • 迪米特法则(Law of Demeter, LoD), 最少知识原则(Principle of Least Knowledge)

其中,前5个原则称为SOLID原则

3类设计模式,共23个

创建型模式(Creational patterns)

  1. 单例模式(Singleton)
  2. 建造者模式(Builder)
  3. 原型模式(Prototype)
  4. 工厂方法模式(Factory method)
  5. 抽象工厂模式(Abstract factory)

结构型模式(Structural patterns)

  1. 代理模式(Proxy)
  2. 组合模式(Composite)
  3. 适配器模式(Adapter)
  4. 装饰模式(Decorator)
  5. 享元模式(Flyweight)
  6. 外观模式(Facade)
  7. 桥接模式(Bridge)

行为型模式(Behavioral patterns)

  1. 策略模式(Strategy)
  2. 状态模式(State)
  3. 责任链模式(Chain of responsibility)
  4. 解释器模式(Interpreter)
  5. 命令模式(Command)
  6. 观察者模式(Observer)
  7. 备忘录模式(Memento)
  8. 迭代器模式(Iterator)
  9. 模版方法模式(Template method)
  10. 访问者模式(Visitor)
  11. 中介者模式(Mediator)

设计模式这么多,这里整理了相关的易混淆的设计模式

这是作者从《Android源码设计模式解析与实战(第二版)》中提取出来的思维导图
以及作者提供的23种UML图的百度云盘

UML图图示样例

评论