23种设计模式图片以及设计模式六大原则
2017-12-24 19:15
211 查看
设计模式六大原则:
单一职责原则(Single Responsibility Principle,SRP )
There should never be more than one reason for a class to change.
里氏替换原则(Liskov Substitution Principle,LSP )
If for each object o1 of type S there is an object o2 of type T such that for all programs P defined in terms of T,the behavior of P is unchanged when o1 is substituted for o2 then S is a subtype of T.(如果对每一个类型为S的对象o1,都有类型为T的对象o2,使得以T定义的所有程序P在所有的对象o1都代换成o2时,程序P的行为没有发生变 化,那么类型S是类型T的子类型。)
Functions that use pointers or references to base classes must beable to use objects of derived classes without knowing it.(所有引用基类的地方必须能透明地使用其子类的 对象。)
依赖倒置原则(Dependence Inversion Principle,DIP)
High level modules should not depend upon low level modules.Both should depend upon
abstractions.Abstractions should not depend upon details.Details
翻译过来,包含三层含义:
●高层模块不应该依赖低层模块,两者都应该依赖其抽象;
● 抽象不应该依赖细节;
● 细节应该依赖抽象。
接口隔离原则 (Interface Segregation Principle,ISP)
● Clients should not be forced to depend upon interfaces that
they don’t use.(客户端不应该依 赖它不需要的接口。)
● The dependency of one class to
another one should depend on the smallest possible interface.(类间的依赖关系应该建立在最小的接口上。)
迪米特法则(Law of Demeter,LoD)也称为最少知识原则(Least Knowledge Principle,LKP)
Only talk to your immediate friends(只与直接的朋友通 信。)
开闭原则 (Open Closed Principle,OCP)
Software entities like classes,modules and functions should be open for extension but closed for
modifications.(一个软件实体如类、模块和函数应该对扩展开放,对修改关闭。)
CSDN显示图片效果不太好
建议直接进入图片链接,进行缩放查看
https://img-blog.csdn.net/20171224190538110?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2h6bTA=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast
单一职责原则(Single Responsibility Principle,SRP )
There should never be more than one reason for a class to change.
里氏替换原则(Liskov Substitution Principle,LSP )
If for each object o1 of type S there is an object o2 of type T such that for all programs P defined in terms of T,the behavior of P is unchanged when o1 is substituted for o2 then S is a subtype of T.(如果对每一个类型为S的对象o1,都有类型为T的对象o2,使得以T定义的所有程序P在所有的对象o1都代换成o2时,程序P的行为没有发生变 化,那么类型S是类型T的子类型。)
Functions that use pointers or references to base classes must beable to use objects of derived classes without knowing it.(所有引用基类的地方必须能透明地使用其子类的 对象。)
依赖倒置原则(Dependence Inversion Principle,DIP)
High level modules should not depend upon low level modules.Both should depend upon
abstractions.Abstractions should not depend upon details.Details
翻译过来,包含三层含义:
●高层模块不应该依赖低层模块,两者都应该依赖其抽象;
● 抽象不应该依赖细节;
● 细节应该依赖抽象。
接口隔离原则 (Interface Segregation Principle,ISP)
● Clients should not be forced to depend upon interfaces that
they don’t use.(客户端不应该依 赖它不需要的接口。)
● The dependency of one class to
another one should depend on the smallest possible interface.(类间的依赖关系应该建立在最小的接口上。)
迪米特法则(Law of Demeter,LoD)也称为最少知识原则(Least Knowledge Principle,LKP)
Only talk to your immediate friends(只与直接的朋友通 信。)
开闭原则 (Open Closed Principle,OCP)
Software entities like classes,modules and functions should be open for extension but closed for
modifications.(一个软件实体如类、模块和函数应该对扩展开放,对修改关闭。)
CSDN显示图片效果不太好
建议直接进入图片链接,进行缩放查看
https://img-blog.csdn.net/20171224190538110?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvc2h6bTA=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast
相关文章推荐
- 设计模式之总结篇(设计模式六大原则以及设计模式三种类型)
- 设计模式-六大设计原则(附加实际开发建议以及计算器例子)
- JAVA23种设计模式小结以及设计原则归纳
- 设计模式的分类以及六大设计原则
- 设计模式分类以及六大原则
- 常见23种设计模式和设计模式六大原则,你用了多少?
- 23种设计模式以及设计原则(一)
- 设计模式——设计模式三大分类以及六大原则
- GOF提出的23种设计模式是哪些 设计模式有创建形、行为形、结构形三种类别 常用的Javascript中常用设计模式的其中17种 详解设计模式六大原则
- 面向对象六大原则和23中设计模式 , 以及记忆方法
- 面向对象的23种设计模式与六大原则
- 23种设计模式以及设计原则(二)
- 代码重构 +设计模式六大原则 + 23种设计模式
- 23种设计模式-设计模式六大原则
- 23种设计模式-设计模式六大原则
- 大话设计模式(读后感)——23种设计模式、六大原则
- 设计模式的六大原则
- 一句话评论设计模式六大原则【转】
- 设计模式六大原则(五)迪米特法则(最少知道原则)
- Java设计模式六大原则之场景应用分析