面向對象設計的原則

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萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章