Agile Design 敏捷设计
The Single-Responsibility Principle (SRP)
单一职责原则
A class should have only one reason to change.
就一个类而言,应该仅有一个引起它变化的原因。
The Open/Closed Principle (OCP)
开放-封闭原则
Software entities(classes, modules, functions, etc.) should be open for extension but closed for modification.
软件实体(类、模块、函数等)应该是可以扩展的,但是不可修改。
The Liskov Substitution Principle (LSP)
里氏替换原则
Subtypes must be substitutable for their base types.
子类型必须能够替换掉它们的基类型。
The Dependency-Inversion Principle (DIP)
依赖倒置原则
A.High-level modules should not depend on low-level modules. Both should depend on abstractions.
高层模块不应该依赖于底层模块。双方应该依赖于抽象。
B.Abstractions should not depend upon details. Details should depend upon abstractions.
抽象不应该依赖于细节。细节应该依赖于抽象。
The Interface Segregation Principle (ISP)
接口隔离原则
Clients should not be forced to depend on methods they do not use.
客户端不应该被迫依赖它们不使用的方法。
Principles of Component Cohesion: Granularity 包的内聚性原则:粒度
The Reuse/Release Equivalence Principle (REP)
重用发布等价原则
The granule of reuse is the granule of release.
重用的粒度就是发布的粒度。
The Common Reuse Principle (CRP)
共同重用原则
The classes in a component are reused together. If you reuse one of the classes in a component, you reuse them all.
一个包中的所有类应该是共同重用的。如果重用了包中的一个类,那么就要重用包中的所有类。
The Common Closure Principle (CCP)
共同封闭原则
The classes in a component should be closed together against the same kinds of changes. A change that affects a component affects all the classes in that component and no other components.
包中的所有类对于同一类性质的变化应该是共同封闭的。一个变化若对一个包产生影响,则将对该包中的所有类产生影响,而对于其他的包不造成任何影响。
Principles of Component Coupling: Stability 包的耦合性原则:稳定
The Acyclic Dependencies Principle (ADP)
无环依赖原则
Allow no cycles in the component dependency graph.
在包的依赖关系图中不允许存在环。
The Stable-Dependencies Principle (SDP)
稳定依赖原则
Depend in the direction of stability.
朝着稳定的方向进行依赖。
The Stable-Abstractions Principle (SAP)
稳定抽象原则
A component should be as abstract as it is stable.
包的抽象程度应该和其稳定程度一致。