ifacethoughts

Common Closure Principle

Common Closure Principle (CCP) is another package design principle which tries to look at maintainability rather than usability. The principle advises on which classes should be packaged together from a change and distribution point of view. It states:

The classes in a package should be closed together against the same kind of changes. A change that affects a package affects all the classes in that package.

Even though most of the class design principles advocate loose coupling between classes, so that they can change without affecting the other, dependencies between classes cannot be avoided. CCP tries to look at classes that are dependent on each other from a code change perspective. Even though Open-Closed Principle (OCP) recomments full closure to code change, it is not always possible. Sometimes some of the class design principles are violated consciously to improve performance, just like denormalization in databases. However this violation should be a conscious decision and the product should be ready for changes because of it.

To enable easy distribution/update/release and maintainability, it is advisable to localise the changes to a package. Only the modified package can then be released, making the update easier. Even if the changes cannot be restricted to a single package, minimal packages should be required to be changed. To get an idea of the code change dependencies, we can take guidance from Law Of Demeter (LOD) principle, which tries to point out classes which know each other’s structures.

Back to Design Principles.

Technorati tags: , , , ,

Copyright Abhijit Nadgouda.

Discussion [Participate or Link]

  1. OO Design Principles on iface thoughts said:

    [...] Common Closure Principle (CCP) [...]

  2. Stable Dependencies Principle on iface thoughts said:

    [...] All the design principles focus on getting the dependencies right between classes and then between packages. This enables high reusability and easier maintenance of software applications. As we have seen in Common Closure Principle, packages can be closed only for certain changes, an absolute closure is difficult. To be able to define a dependency chain which can help in localising the changes and create a system which is still flexible but not prone to erroneous changes, we need to look at stability of packages. [...]

  3. The Science of Packages said:

    [...] should be packed together according to the The Common Closure Principle. Which states that classes that are likely to change at the same time because of their high [...]

Say your thought!

Who are you?

If you want to use HTML you can use these tags: <a>, <em>, <strong>, <abbr>, <code>, <blockquote>. Closing the tags will be appreciated as this site uses valid XHTML.

freshthoughts

contactme

Abhijit Nadgouda
iface Consulting
India
+91 9819820312
Y!: anadgouda
GTalk: anadgouda@gmail.com
MSN: anadgouda@hotmail.com
Skype: anadgouda
My bookmarks

currentproject

Complete Wellbeing

badgesand...

This is the weblog of Abhijit Nadgouda where he writes down his thoughts on software development and related topics. You are invited to subscribe to the feed to stay updated or check out more subscription options. Or you can choose to browse by one of the topics.

Twitter - Using Envy Code R and liking it. Thank you Damien. http://tinyurl.com/688mft