面向对象设计的原则

1. The Open/Closed Principle: Software entities (classes, modules, etc) should be open for extension, but closed for modification.

开关原则:类和模块应该对扩展开放,对修改关闭

2. The Liskov Substitution Principle: Derived classes must be usable through the base class interface without the need for the user to know the difference. [See previous tip about LSP]

派生类应该可以通过基类接口访问,不需要用户知道他们的区别

3. The Dependency Inversion Principle: Details should depend upon abstractions. Abstractions should not depend upon details.

依赖倒置原则:实现细节应该依赖于抽象

4. The Interface Segregation Principle: Many client specific interfaces are better than one general purpose interface/

接口分离原则:多个具体客户接口,优於单个通用接口

5. The Reuse/Release Equivalency Principle: The granule of reuse is the same as the granule of release. Only components that are released through a tracking system can be effectively reused.

重用与发布等价原则:重用性的粒度与发布的粒度是一样的

6. The Common Closure Principle: Classes that change together, belong together.

闭包原则:一起修改的类,属于一组

7. The Common Reuse Principle: CClasses that aren’t reused together should not be grouped together.

重用原则:不一起重用的类,不属于一组

8. The Acyclic Dependencies Principle: The dependency structure for released components must be a directed acyclic graph. There can be no cycles.

9. The Stable Dependencies Principle: Dependencies between released categories must run in the direction of stability. The dependee must be more stable than the depender.

10. The Stable Abstractions Principle: The more stable a class category is, the more it must consist of abstract classes. A completely stable category should consist of nothing but abstract classes.

发布了42 篇原创文章 · 获赞 6 · 访问量 9万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章