There are five principles of class design (aka SOLID)

The Single Responsibility Principle(SRP):
Each responsibility should be a separate class, because each responsibility is an axis of change.
A class should have one, and only one, reason to change.
If a change to the business rules causes a class to change, then a change to the database schema, GUI, report format, or any other segment of the system should not force that class to change.


Dependency Inversion Principle(DIP):
A. High level modules should not depend upon low level modules. Both should depend upon abstractions.
B. Abstractions should not depend upon details. Details should depend upon abstractions.


Interface Segregation Principle(ISP):
The dependency of one class to another one should depend on the smallest possible interface.


Liskov Substitution Principle(LSP):
What is wanted here is something like the following substitution property: 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."


Open Closed Principle(OCP):

Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification.


参考:
http://c2.com/cgi/wiki?PrinciplesOfObjectOrientedDesign

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值