The first five principles are principles of class design. They are :
SRP | The Single Responsiblity Principle | “A class should have one, and only, one reason to change.“ |
OCP | The Open Closed Principle | You shloud be able to extend a classes behavior, without modifying it. |
LSP | The Liskov Substitution Principle | Derived classes must be substitutable for their base classes. |
ISP | The Interface Segeregation Principle | Make fine grained interfaces that are client specific. |
DIP | The Dependency Inversion Principle | Depend on abstraction, not on concretions. |
추가 설명
- OCP - Software entities (classes, modules, etc) should be open for extension, but closed for modification.
- LSP - Derived classes must usable through the base class interface without the need for the user to know the difference
- DIP
A. High-level modules should not depend on low-level modules. Both should depend on abstractions.
B. Abstractions should not depend on details. Details should depend on abstractions.
The next six principles are about packages.
The first three package principles are about package cohesion, they tell us what to put inside packages:
REP | The Release Reuse Equivalency Principle | The granule of reuse is the granule of release. |
CCP | The Common Closure Principle | classes that change together are packaged together. |
CRP | The Common Reuse Principle | classes that are used together are packaged toghether. |
추가 설명
- REP - 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.
- CCP - Classes within a released component should share common closure. That is, if one needs to be changed, they all are likely to need to be changed. What affects one, affects all.
- CRP - Classes within a released componen should be reused together. That is, it is impossible to separate the components from each other in order to reuse less than the total.
The last three principles are about the couplings between packages, and talk about metrics that evaluate the structure of a system.
ADP | The Acyclic Dependencies Principle | The dependency graph of package must have no cycles.. |
SDP | The Stable Dependencies Principle | Depend in the direction of stability |
SAP | The Stable Abstractions Principle | Abstractness increases with stability |
추가 설명
- ADP - The dependency structure for released components must be a DAG.There can be no cycles.
- SDP - Dependencies between released components must run in the direction of stability. The dependee must be more stable than the depender.
- SAP - The more stable a released component is, the more it mustconsist of abstract classes. A completely stable componentshould consist of nothing but abstract classes.