--【读书笔记】
1. 单一职责(Single Responsibility Principle)
There should never be more than one reason for a class to chenge.
单一职责原则提出了一个编写程序的标准,用“职责”或“变化原因”来衡量接口或者类设计得是否优良,但是职责和变化原因都是不可度量的,因项目而异,因环境而异。
2. 里氏替换原则(Liskov Subsitution Principle)
A 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 substitued for o2 then S is a subtype of T.
B Functions that use pointers or references to base classes must be able to user objects of derived classes without knowing it .
3. 依赖倒置原则
依赖体现在抽象层,不体现在具体的实现层。
4. 接口隔离原则
定义最小的接口,使得接口更加的灵活,客户端不依赖于不需要的接口。
clinets should not be forced to depend upon interfaces that they don't use.
clients dependcy of one class to another one should depend on the smallest possible interface.
5. 迪米特法则(Law of Demeter),最少知识原则(Least Knowledge Principle)
一个对象应该与其他对象有最少的了解。
6. 开闭原则
Software entities like classes,modules and functions should be open for extension but close for modifications.
分享到:
相关推荐
设计模式体现的是软件设计的思想, 而不是软件技术, 它重在使用接口与抽象类来解决 各种问题。
个人整理的比较全面的 设计模式六大原则与类的六种关系
php 设计模式六大原则 单一职责原则 里氏替换原则 依赖倒置原则 接口隔离原则 迪米特法则 开闭原则 word版
详细介绍设计模式的六大原则,有不足之处希望大家多指教。参考《设计模式之禅》
对设计模式六大原则的一点总结,欢迎免费下载。
设计模式六大原则详解 设计模式原则详解 设计模式原则详解
详细介绍了设计模式六大原则,配有示例代码和图片,有开闭原则,单一职责原则,里氏替换原则,依赖倒置原则,接口隔离原则,迪米特法则等等。
设计模式六大原则(1):单一职责原则 设计模式六大原则(2):里氏替换原则 设计模式六大原则(3):依赖倒置原则 设计模式六大原则(4):接口隔离原则 设计模式六大原则(5):迪米特法则 设计模式六大原则...
文档为23种设计模式中的15种设计模式和设计模式六大原则,里面写的某种模式的优缺点,适用场景,具体代码,注意事项,典型应用。具体写的挺好,希望能帮助你。
设计模式六大原则 .docx
1.单一职责原则: 不要存在多于一个导致类变更的原因 ...接口隔离原则告诉我们在设计接口的时候要精简单一;迪米特法则告诉我们要降低耦合。而开闭原则是总纲,他告诉我们要对扩展开放,对修改关闭。
1. 单一职责原则 2. 依赖倒置原则 3. 迪米特法则 4. 开放-封闭原则 5. 里氏替换原则(了解) 6. 接口隔离原则(了解)
对设计模式六大原则的一点总结,欢迎免费下载。
NULL 博文链接:https://lijie-insist.iteye.com/blog/2190970