介绍一下RobertC.Martin提出的面向对象的设计原则 中的全再利用原则。参考文档(http://www.objectmentor.com/resources/articles/granularity.pdf )。
全再利用原则(CRP):The Common Reuse Principle。是为了解决包设计的凝集问题的。
·包里面的类能够一起被再利用,如果重用了包中的一个类,那么就要重用包中的所有类。( The classes in a package are reused together. If you reuse one of the classes in a package, you reuse them all.)。
· 不能够被一起再利用的类不要放在同一个包里面。( Classes that aren’t reused together should not be grouped together)。
面向对象的所有这些原则在实践中完全遵守是几乎不可能的,主要是没有那么时间和金钱让我们去仔细琢磨。不过我们了解认识了这些原则后,在设计的时候尽量使自己的产品分离性更高,效率好。易读,易扩展,易维护。