元月's blog 元月's blog
首页
  • 基础
  • 并发编程
  • JVM
  • Spring
  • Redis篇
  • Nginx篇
  • Kafka篇
  • Otter篇
  • Shardingsphere篇
  • 设计模式
  • MySQL
  • Oracle
  • 基础
  • 操作系统
  • 网络
  • 数据结构
  • 技术文档
  • Git常用命令
  • GitHub技巧
  • 博客搭建
  • 开发工具
更多

元月

临渊羡鱼,不如退而结网
首页
  • 基础
  • 并发编程
  • JVM
  • Spring
  • Redis篇
  • Nginx篇
  • Kafka篇
  • Otter篇
  • Shardingsphere篇
  • 设计模式
  • MySQL
  • Oracle
  • 基础
  • 操作系统
  • 网络
  • 数据结构
  • 技术文档
  • Git常用命令
  • GitHub技巧
  • 博客搭建
  • 开发工具
更多
  • 设计模式

    • 设计模式简介
      • 一、设计模式的目的
      • 二、设计模式的六大原则
        • 1、开闭原则(Open Close Principle)
        • 2、里氏代换原则(Liskov Substitution Principle)
        • 3、合成复用原则(Composite Reuse Principle)
        • 4、依赖倒转原则(Dependence Inversion Principle)
        • 5、接口隔离原则(Interface Segregation Principle)
        • 6、迪米特法则,又称最少知道原则(Law of Demeter)
      • 三、设计模式的类型
        • 1、创建型模式(Creational Patterns)
        • 2、结构型模式(Structural Patterns)
        • 3、行为型模式(Behavioral Patterns)
    • 设计模式之单例模式
    • 设计模式之工厂模式
    • 设计模式之原型模式
    • 设计模式之建造者模式
    • 设计模式之适配器模式
    • 设计模式之桥接模式
    • 设计模式之组合模式
    • 设计模式之装饰器模式
    • 设计模式之外观模式
    • 设计模式之享元模式
    • 设计模式之代理模式
    • 设计模式之责任链模式
    • 设计模式之命令模式
    • 设计模式之解释器模式
    • 设计模式之迭代器模式
    • 设计模式之中介者模式
    • 设计模式之备忘录模式
    • 设计模式之观察者模式
    • 设计模式之状态模式
    • 设计模式之策略模式
    • 设计模式之模版模式
    • 设计模式之访问者模式
    • 设计模式辨析篇
  • 高可用

  • 系统设计
  • 设计模式
元月
2022-07-20
目录

设计模式简介

# 设计模式简介

# 一、设计模式的目的

1、提高代码复用性

2、提高代码可读性

3、提高代码扩展性

4、提高代码可靠性

5、高内聚、低耦合

# 二、设计模式的六大原则

# 1、开闭原则(Open Close Principle)

​ 对扩展开放,对修改关闭

# 2、里氏代换原则(Liskov Substitution Principle)

​ 任何基类可以出现的地方,子类一定可以出现。LSP 是继承复用的基石

# 3、合成复用原则(Composite Reuse Principle)

​ 尽量使用合成/聚合的方式,而不是使用继承

# 4、依赖倒转原则(Dependence Inversion Principle)

​ 针对接口编程,依赖于抽象而不依赖于具体

# 5、接口隔离原则(Interface Segregation Principle)

​ 使用多个隔离的接口,比使用单个接口要好。它强调降低依赖,低耦合

# 6、迪米特法则,又称最少知道原则(Law of Demeter)

​ 一个实体应当尽量少地与其他实体之间发生相互作用,使得系统功能模块相对独立

# 三、设计模式的类型

# 1、创建型模式(Creational Patterns)

关注对象的创建。提供了一种在创建对象的同时隐藏创建逻辑的方式,而不是使用 new 运算符直接实例化对象

  • 工厂模式(Factory Pattern)
  • 抽象工厂模式(Abstract Factory Pattern)
  • 单例模式(Singleton Pattern)
  • 建造者模式(Builder Pattern)
  • 原型模式(Prototype Pattern)

# 2、结构型模式(Structural Patterns)

关注类和对象的组合。继承的概念被用来组合接口和定义组合对象获得新功能的方式

  • 装饰器模式(Decorator Pattern)
  • 适配器模式(Adapter Pattern)
  • 外观模式(Facade Pattern)
  • 代理模式(Proxy Pattern)
  • 享元模式(Flyweight Pattern)
  • 组合模式(Composite Pattern)
  • 桥接模式(Bridge Pattern)

# 3、行为型模式(Behavioral Patterns)

关注对象之间的行为

  • 观察者模式(Observer Pattern)
  • 解释器模式(Interpreter Pattern)
  • 模板模式(Template Pattern)
  • 访问者模式(Visitor Pattern)
  • 责任链模式(Chain of Responsibility Pattern)
  • 迭代器模式(Iterator Pattern)
  • 命令模式(Command Pattern)
  • 中介者模式(Mediator Pattern)
  • 策略模式(Strategy Pattern)
  • 备忘录模式(Memento Pattern)
  • 状态模式(State Pattern)
#设计模式
设计模式之单例模式

设计模式之单例模式→

最近更新
01
otter二次开发-支持按目标端主键索引Load数据
08-03
02
mvnw简介
06-21
03
gor流量复制工具
06-03
更多文章>
Theme by Vdoing | Copyright © 2022-2024 元月 | 粤ICP备2022071877号-1
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式