设计模式一般包含模式名称、问题、目的、解决方案、效果等组成要素,其中关键要素是模式名称、问题、解决方案和效果。模式名称(Pattern Name)通过一两个词来描述模式的问题、解决方案和效果,以便更好地理解模式并方便开发人员之间的交流,绝大多数模式都是根据其功能或模式结构来命名的(GoF设计模式中没有一个模式用人名命名,微笑);问题(Problem)描述了应该在何时使用模式,它包含了设计中存在的问题以及问题存在的原因;解决方案(Solution)描述了一个设计模式的组成成分,以及这些组成成分之间的相互关系,各自的职责和协作方式,通常解决方案通过UML类图和核心代码来进行描述;效果(Consequences)描述了模式的优缺点以及在使用模式时应权衡的问题。
| 设计模式类型 | 设计模式 |
|---|---|
| 单例模式 Singleton Pattern | |
| 简单工厂模式 Simple Factory Pattern | |
| 创建型模式 Creational Pattern | 工厂方法模式 Factory Method Pattern |
| 抽象工厂模式 Abstract Factory Pattern | |
| 原型模式 Prototype Pattern | |
| 建造者模式 Builder Pattern | |
| *** | |
| 适配器模式 Adapter Pattern | |
| 桥接模式 Bridge Pattern | |
| 组合模式 Composite Pattern | |
| 结构型模式 Structural Pattern | 装饰模式 Decorator Pattern |
| 外观模式 Façade Pattern | |
| 享元模式 Flyweight Pattern | |
| 代理模式 Proxy Pattern | |
| *** | |
| 职责链模式 Chain of Responsibility Pattern | |
| 命令模式 Command Pattern | |
| 解释器模式 Interpreter Pattern | |
| 迭代器模式 Iterator Pattern | |
| 中介者模式 Mediator Pattern | |
| 行为型模式 Behavioral Pattern | 备忘录模式 Memento Pattern |
| 观察者模式 Observer Pattern | |
| 状态模式 State Pattern | |
| 策略模式 Strategy Pattern | |
| 模板方法模式 Template Method Pattern | |
| 访问者模式 Visitor Pattern |