具体解析

创建型

结构型

7个原则

  1. 单一职责原则【SINGLE RESPONSIBILITY PRINCIPLE】: 一个类负责一项职责。
  2. 里氏替换原则【LISKOV SUBSTITUTION PRINCIPLE】: 继承与派生的规则。
  3. 依赖倒置原则【DEPENDENCE INVERSION PRINCIPLE】: 高层模块不应该依赖低层模块,二者都应该依赖其抽象;抽象不应该依赖细节;细节应该依赖抽象。即针对接口编程,不要针对实现编程。
  4. 接口隔离原则【INTERFACE SEGREGATION PRINCIPLE】: 建立单一接口,不要建立庞大臃肿的接口,尽量细化接口,接口中的方法尽量少。
  5. 迪米特法则【LOW OF DEMETER】: 低耦合,高内聚。
  6. 开闭原则【OPEN CLOSE PRINCIPLE】: 一个软件实体如类、模块和函数应该对扩展开放,对修改关闭。
  7. 组合/聚合复用原则【Composition/Aggregation Reuse Principle(CARP) 】: 尽量使用组合和聚合少使用继承的关系来达到复用的原则。

24大设计模式

简单工厂一般不提,所以就是 23 种。

概览图

23种设计模式【Java版】解析

一览表

类型 模式名称 学习难度 使用频率
创建型模式 Creational Pattern 单例模式 Singleton Pattern ★☆☆☆☆ ★★★★☆
创建型模式 Creational Pattern 简单工厂模式 Simple Factory Pattern ★★☆☆☆ ★★★☆☆
创建型模式 Creational Pattern 工厂方法模式 Factory Method Pattern ★★☆☆☆ ★★★★★
创建型模式 Creational Pattern 抽象工厂模式 Abstract Factory Pattern ★★★★☆ ★★★★★
创建型模式 Creational Pattern 原型模式 Prototype Pattern ★★★☆☆ ★★★☆☆
创建型模式 Creational Pattern 建造者模式 Builder Pattern ★★★★☆ ★★☆☆☆
结构型模式 Structural Pattern 适配器模式 Adapter Pattern ★★☆☆☆ ★★★★☆
结构型模式 Structural Pattern 桥接模式 Bridge Pattern ★★★☆☆ ★★★☆☆
结构型模式 Structural Pattern 组合模式 Composite Pattern ★★★☆☆ ★★★★☆
结构型模式 Structural Pattern 装饰模式 Decorator Pattern ★★★☆☆ ★★★☆☆
结构型模式 Structural Pattern 外观模式 Façade Pattern ★☆☆☆☆ ★★★★★
结构型模式 Structural Pattern 享元模式 Flyweight Pattern ★★★★☆ ★☆☆☆☆
结构型模式 Structural Pattern 代理模式 Proxy Pattern ★★★☆☆ ★★★★☆
行为型模式 Behavioral Pattern 职责链模式 Chain of Responsibility Pattern ★★★☆☆ ★★☆☆☆
行为型模式 Behavioral Pattern 命令模式 Command Pattern ★★★☆☆ ★★★★☆
行为型模式 Behavioral Pattern 解释器模式 Interpreter Pattern ★★★★★ ★☆☆☆☆
行为型模式 Behavioral Pattern 迭代器模式 Iterator Pattern ★★★☆☆ ★★★★★
行为型模式 Behavioral Pattern 中介者模式 Mediator Pattern ★★★☆☆ ★★☆☆☆
行为型模式 Behavioral Pattern 备忘录模式 Memento Pattern ★★☆☆☆ ★★☆☆☆
行为型模式 Behavioral Pattern 观察者模式 Observer Pattern ★★★☆☆ ★★★★★
行为型模式 Behavioral Pattern 状态模式 State Pattern ★★★☆☆ ★★★☆☆
行为型模式 Behavioral Pattern 策略模式 Strategy Pattern ★☆☆☆☆ ★★★★☆
行为型模式 Behavioral Pattern 模板方法模式 Template Method Pattern ★★☆☆☆ ★★★☆☆
行为型模式 Behavioral Pattern 访问者模式 Visitor Pattern ★★★★☆ ★☆☆☆☆

关联关系

23种设计模式【Java版】解析

知识体系图

23种设计模式【Java版】解析

参考

Java设计模式

图说设计模式

Java设计模式

相关文章: