Go & Java 实现。
设计模式是对软件系统中常用写法的总结与抽象,不经意间可能就使用某种了设计模式 🚀
| 序号 | 原则名称 | 英文名称 | 简述 |
|---|---|---|---|
| 1 | 开放封闭原则 | Open Close Principle | 对扩展开放,对修改封闭 |
| 2 | 里氏替换原则 | Liskov Substitution Principle | 子类可以替换父类并保持功能正确性 |
| 3 | 依赖倒置原则 | Dependence Inversion Principle | 依赖于抽象而不是具体实现 |
| 4 | 接口隔离原则 | Interface Segregation Principle | 客户端不应依赖它不需要的接口 |
| 5 | 迪米特法则 | Demeter Principle | 最少知识原则,降低耦合度 |
| 6 | 单一职责原则 | Single Responsibility Principle | 一个类只负责一项职责 |
| 序号 | 模式名称 | 英文名称 | 目录 |
|---|---|---|---|
| 1 | 单例模式 | Singleton Design Pattern | build-type/01_singleton |
| 2 | 工厂模式 | Factory Design Pattern | build-type/02_factory |
| 3 | 建造者模式 | Builder Design Pattern | build-type/03_builder |
| 4 | 原型模式 | Prototype Design Pattern | build-type/04_prototype |
| 序号 | 模式名称 | 英文名称 | 目录 |
|---|---|---|---|
| 5 | 代理模式 | Proxy Design Pattern | struct-type/05_proxy |
| 6 | 桥接模式 | Bridge Design Pattern | struct-type/06_bridge |
| 7 | 装饰器模式 | Decorator Design Pattern | struct-type/07_decorator |
| 8 | 适配器模式 | Adapter Design Pattern | struct-type/08_adapter |
| 9 | 门面模式 | Facade Design Pattern | struct-type/09-facade |
| 10 | 组合模式 | Composite Design Pattern | struct-type/10-composite |
| 11 | 享元模式 | Flyweight Design Pattern | struct-type/11-flyweight |
| 序号 | 模式名称 | 英文名称 | 目录 |
|---|---|---|---|
| 12 | 观察者模式 | Observer Design Pattern | action-type/12-observer |
| 13 | 模板方法模式 | Template Design Pattern | action-type/13-template |
| 14 | 策略模式 | Strategy Design Pattern | action-type/14-stratery |
| 15 | 职责链模式 | Chain Of Responsibility Design Pattern | action-type/15-chain-of-responsibility |
| 16 | 状态模式 | State Design Pattern | action-type/16-state |
| 17 | 迭代器模式 | Iterator Design Pattern | action-type/17-lterator |
| 18 | 访问者模式 | Visitor Design Pattern | action-type/18-visitor |
| 19 | 备忘录模式 | Memento Design Pattern | action-type/19-memento |
| 20 | 命令模式 | Command Design Pattern | action-type/20-command |
| 21 | 解释器模式 | Interpreter Design Pattern | action-type/21-interpreter |
| 22 | 中介者模式 | Mediator Design Pattern | action-type/22-mediator |
| 常用程度 | 设计模式 | 应用场景描述 |
|---|---|---|
| 非常常用 | 工厂模式 | 封装对象创建逻辑,解耦对象的创建和使用 |
| 非常常用 | 策略模式 | 算法族的封装与切换,避免大量 if-else |
| 非常常用 | 观察者模式 | 一对多的依赖关系,事件驱动编程 |
| 常用 | 单例模式 | 全局唯一实例,如配置管理、线程池 |
| 常用 | 代理模式 | 控制对象访问,增加中间层处理 |
| 常用 | 装饰器模式 | 动态添加职责,比继承更灵活 |
| 常用 | 适配器模式 | 接口转换,兼容不同接口 |
| 常用 | 模板方法模式 | 定义算法骨架,子类实现具体步骤 |
| 常用 | 职责链模式 | 请求处理链,解耦请求发送者和接收者 |
| 常用 | 迭代器模式 | 遍历集合元素,隐藏内部结构 |
| 较少使用 | 建造者模式 | 构建复杂对象,分步骤创建 |
| 较少使用 | 桥接模式 | 分离抽象和实现,独立变化 |
| 较少使用 | 门面模式 | 简化复杂子系统的接口 |
| 较少使用 | 组合模式 | 树形结构,统一处理单个和组合对象 |
| 较少使用 | 状态模式 | 对象状态改变时改变行为 |
| 较少使用 | 命令模式 | 将请求封装为对象,支持撤销等操作 |
| 较少使用 | 备忘录模式 | 保存和恢复对象状态 |
| 较少使用 | 中介者模式 | 封装对象间的交互,减少耦合 |
| 不常用 | 原型模式 | 通过克隆创建对象 |
| 不常用 | 享元模式 | 共享对象,减少内存占用 |
| 不常用 | 访问者模式 | 在不修改类的前提下增加新操作 |
| 不常用 | 解释器模式 | 定义语言文法,解释语句 |
- https://github.com/mohuishou/go-design-pattern
- https://refactoringguru.cn/design-patterns/
- https://github.com/senghoo/golang-design-pattern
- https://github.com/youlookwhat/DesignPattern

