【设计模式】设计原则和常见的23种经典设计模式

设计模式

1. 设计原则(记忆口诀:SOLID)【记忆口诀:单开里依接迪合(单开礼仪接地和)】
(1)单一职责原则(Single Responsibility Principle, SRP)
(2)开闭原则(Open-Closed Principle, OCP)
(3)里氏替换原则(Liskov Substitution Principle, LSP)
(4)依赖倒置原则(Dependence Inversion Principle, DIP)
(5)接口隔离原则(Interface Segregation Principle, ISP)
(6)迪米特法则(最少知道原则)(Law of Demeter, LoP)
(7)合成复用原则(Composite Reuse Principle, CRP)
2. 常见的23种经典设计模式
2.1 创建型模式(5种)【记忆口诀:创工抽单建原(床工臭蛋减员)】
(1)工厂模式(Factory Pattern)
(2)抽象工厂模式(Abstract Factory Pattern)
(3)单例模式(Singleton Pattern)
(4)建造者模式(Builder Pattern)
(5)原型模式(Prototype Pattern)
2.2 结构型模式(7种)【记忆口诀:结适装代外桥组享(解释装袋外侨租箱)】
(1)适配器模式(Adapter Pattern)
(2)装饰器模式(Decorator Pattern)
(3)代理模式(Proxy Pattern)
(4)外观模式(Facade Pattern)
(5)桥接模式(Bridge Pattern)
(6)组合模式(Composite Pattern)
(7)享元模式(Flyweight Pattern)
2.3 行为型模式(11种)【记忆口诀:行策模观迭责命备状访中解(行测暮光蝶这名被撞房中介)】
(1)策略模式(Strategy Pattern)
(2)模板模式(Template Pattern)
(3)观察者模式(Observer Pattern)
(4)迭代器模式(Iterator Pattern)
(5)责任链模式(Chain of Responsibility Pattern)
(6)命令模式(Command Pattern)
(7)备忘录模式(Memento Pattern)
(8)状态模式(State Pattern)
(9)访问者模式(Visitor Pattern)
(10)中介者模式(Mediator Pattern)
(11)解释器模式(Interpreter Pattern)

※ 本文小结

在这里插入图片描述


参考资料

参考书籍:《设计模式的艺术 / 刘伟著》

参考网站:设计模式 | 菜鸟教程

  • 11
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值