23种设计模式图片以及设计模式六大原则

设计模式六大原则:

  1. 单一职责原则(Single Responsibility Principle,SRP )
    There should never be more than one reason for a class to change.

  2. 里氏替换原则(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.(所有引用基类的地方必须能透明地使用其子类的 对象。)

  3. 依赖倒置原则(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
    翻译过来,包含三层含义:
    ●高层模块不应该依赖低层模块,两者都应该依赖其抽象;
    ● 抽象不应该依赖细节;
    ● 细节应该依赖抽象。

  4. 接口隔离原则 (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.(类间的依赖关系应该建立在最小的接口上。)

  5. 迪米特法则(Law of Demeter,LoD)也称为最少知识原则(Least Knowledge Principle,LKP)
    Only talk to your immediate friends(只与直接的朋友通 信。)

  6. 开闭原则 (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
23种设计模式图片以及设计模式六大原则_第1张图片

你可能感兴趣的:(23种设计模式图片以及设计模式六大原则)