YC Yc.W home Systems · C++ · AI Infrastructure
Computer Science · Reference

Book-深入设计模式

reference Historical context Imported / attributed Use caution
Explore all Computer Science notes →

https://refactoringguru.cn/design-patterns

https://github.com/RefactoringGuru

https://github.com/RefactoringGuru/design-patterns-cpp


设计模式是软件设计中常见问题的典型解决方案。 它们就像能根据需求进行调整的预制蓝图, 可用于解决代码中反复出现的设计问题。

  • 最基础的、 底层的模式通常被称为惯用技巧。 这类模式一般只能在一种编程语言中使用。

  • 最通用的、 高层的模式是构架模式。 开发者可以在任何编程语言中使用这类模式。 与其他模式不同, 它们可用于整个应用程序的架构设计。


所有模式可以根据其意图或目的来分类。 本书覆盖了三种主要的模式类别:

  • 创建型模式提供创建对象的机制, 增加已有代码的灵活性和可复用性。

  • 结构型模式介绍如何将对象和类组装成较大的结构, 并同时保持结构的灵活和高效。

  • 行为模式负责对象间的高效沟通和职责委派。


设计模式目录

  1. 创建型模式 工厂方法 / Factory Method 抽象工厂 / Abstract Factory 生成器 / Builder 原型 / Prototype 单例 / Singleton

  2. 结构型模式 适配器 / Adapter 桥接 / Bridge 组合 / Composite 装饰 / Decorator 外观 / Facade 享元 / Flyweight 代理 / Proxy

  3. 行为模式 责任链 / Chain of Responsibility 命令 / Command 迭代器 / Iterator 中介者 / Mediator 备忘录 / Memento 观察者 / Observer 状态 / State 策略 / Strategy 模板方法 / Template Method 访问者 / Visitor

(图片缺失,未随博客园迁移:.\Design pattern catalog.jpeg) 设计模式目录


SOLID 原则

  • S: 单一职责原则
  • O: 开闭原则
  • L: 里氏替换原则
  • I: 接口隔离原则
  • D: 依赖倒置原则

← Previous Linux-菜鸟教程