设计原则 Design Principle
Design Principle设计原则
最近由于碰到要参与设计一个音频处理系统,有人提议用一个大的全局变量结构体来做状态信息交流的地方,引起了我对设计一个系统的思考,于是找到了如下资料,当然,关于这个系统也是有待验证,不能说全局变量就是不好,因为这个系统并不会并发执行,而且资源充足。 我反正有点疑虑,但是会继续验证。
以下为Gof的六大设计原则,出自《设计模式》。
Single Responsibility Principle -SRP
There should never be more than one reason for a class to change.
Open Closed Principle – OCP
Software entities like classes, modules and functions should be open for extension but closed for modifications.
Liskov Substitution Principle - LSP
Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it.
Least Knowledge Principle - LKP
Only talk to you immediate friends.
Interface Segregation Principle - ISP
The dependency of one class to another one should depend on the smallest possible interface.
Dependence Inversion Principle - DIP
High level modules should not depends upon low level modules. Both should depend upon abstractions. Abstractions should not depend upon details. Details should depend upon abstractions.
剩下的个人认为是非常简单实用。
Don't repeat yourself – DRY
Keep it simple and stupid – KISS
High Cohesion and Low Coupling – HCLC
Design by Contract - DBC
You aren't gonna need it - YAGNI
参考的文章:
http://www.cnblogs.com/areliang/archive/2006/03/07/345111.html