设计模式的六大原则

--【读书笔记】

 

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值