Skip to content

设计模式 ​

23种设计模式及其在Java/Spring中的应用。

目录 ​

创建型模式 ​

结构型模式 ​

行为型模式 ​

设计原则 ​

SOLID原则 ​

  • S - 单一职责原则 (Single Responsibility)
  • O - 开闭原则 (Open-Closed)
  • L - 里氏替换原则 (Liskov Substitution)
  • I - 接口隔离原则 (Interface Segregation)
  • *D (Dependency Inversion)

其他原则 ​

  • 迪米特法则 (Law of Demeter)
  • 合成复用原则 (Composite Reuse)

Spring中的设计模式 ​

  • 单例模式:Spring Bean默认单例
  • 工厂模式:BeanFactory
  • 代理模式:AOP
  • 模板方法:JdbcTemplate、RestTemplate
  • 观察者模式:ApplicationListener
  • 策略模式:Resource接口

Released under the MIT License.