聊聊设计模式

什么是设计模式

首先说下什么是设计模式,设计模式准确的来说应该是前辈总结下来的最佳实践。

https://www.cnblogs.com/xuan666/articles/10643017.html(此博客写很很完善,应该有部分借用了《大话设计模式》这本书中的一些场景,语言是用c#)

设计模式的六大原则

单一原则、里氏替换原则、依赖倒置原则、接口隔离原则、迪米特法则、开闭原则,这6大原则是建议啊 ,只能说尽量保证,但也可以不遵守

设计模式三大类型

创建型:提供了一种在创建对象的同时隐藏创建逻辑的方式,而不是使用 new 运算符直接实例化对象。这使得程序在判断针对某个给定实例需要创建哪些对象时更加灵活。

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

行为型:关注对象之间的通信。

创建型设计模式

工厂模式(Factory Pattern)

抽象工厂模式(Abstract Factory Pattern)

单例模式(Singleton Pattern)

建造者模式(Builder Pattern)

原型模式(Prototype Pattern)

结构型设计模式

适配器模式(Adapter Pattern)

桥接模式(Bridge Pattern)

过滤器模式(Filter、Criteria Pattern)

组合模式(Composite Pattern)

装饰器模式(Decorator Pattern)

外观模式(Facade Pattern)

享元模式(Flyweight Pattern)

代理模式(Proxy Pattern)

行为型设计模式

责任链模式(Chain of Responsibility Pattern)

命令模式(Command Pattern)

解释器模式(Interpreter Pattern)

迭代器模式(Iterator Pattern)

中介者模式(Mediator Pattern)

备忘录模式(Memento Pattern)

观察者模式(Observer Pattern)

状态模式(State Pattern)

空对象模式(Null Object Pattern)

策略模式(Strategy Pattern)

模板模式(Template Pattern)

访问者模式(Visitor Pattern)

 

原文地址:https://www.cnblogs.com/YorkQi/p/14478679.html