您的位置:首页 > 其它

面向对象设计(OOD) 包原则

2008-11-07 09:46 253 查看
1、Stable Abstractions Principle (SAP):稳定抽象等价原则

    Packages that are maximally stable should be maximally abstract. Instable packages should be concrete. The abstraction of a package should be in proportion to its stability.
    最稳定的包应该是最抽象的包。不稳定的包应该是具体的包。包的抽象程度跟它的稳定性成正比。

 

2、Stable Dependencies Principle (SDP):稳定依赖原则

    The dependencies between packages in a design should be in the direction of the stability of the packages. A package should only depend upon packages that are more stable that it is.
    一个设计中的包之间的依赖应该朝着稳定的方向进行。一个包只应该依赖那些比自己更稳定的包。

 

3、The dependency structure between packages must be a directed acyclic graph (DAG). That is, there must be no cycles in the dependency structure.
包之间的依赖结构必须是一个直接的无环图形(DAG)。也就是说,在依赖结构中不允许出现环(循环依赖)。

 

4、The Common Closure Principle (CCP):共同封闭原则

    The classes in a package should be closed together against the same kinds of changes. a change that affects a package affects all the classes in that package.
    一个包中所有的类应该对同一种类型的变化关闭。一个变化影响一个包,便影响了包中所有的类。

 

5、The Common Reuse Principle (CRP):全部重用原则

    The classes in a package are reused together. If you reuse one of the classes in a package, you reuse them all.
    包的所有类被一起重用。如果你重用了其中的一个类,就重用全部。

 

6、The Release Reuse Equivalency Principle (REP):重用发布等价原则

    The granule of reuse is the granule of release.重用粒度等价于发布粒度。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息