面向对象:闭锁性共通原则(CCP)

来源:互联网 发布:好源码 编辑:程序博客网 时间:2024/04/30 00:03

    介绍一下RobertC.Martin提出的面向对象的设计原则中的闭锁性共通原则。参考文档(http://www.objectmentor.com/resources/articles/Principles_and_Patterns.pdf)。   
    闭锁性共通原则(CCP):The Common Closure Principle 。是为了解决包设计的凝集问题的。

    包中的所有类对于同一类性质的变化应该是共通封闭的。一个变化若对一个包产生影响,则将对该包中的所有类产生影响,而对于其他的包不造成任何影响The classes in a package should be closed together against the samekinds of changes. a change that affects a package affects all theclasses in that package.)。

   还有就是因为同一类性质的变化而被修改的类应该放在同一个包内Classes that change together, belong together.)。

原创粉丝点击