Tuesday, March 15. 2011

In this blog post I will give you a brief introduction into the Coupling Between Objects
metric, that is one of the metrics calculated by the static code analysis tool
PHP_Depend.

The Coupling Between Objects or CBO metric was originally
defined by Chidamber & Kemerer in their IEEE paper "A Metrics Suite
for Object Oriented Design" [1]. This
software metric represents the number of other types a class or interface is
coupled to. The CBO metric is calculated for classes and interfaces.
It counts the unique number of reference types that occur through method
calls, method parameters, return types, thrown exceptions and accessed
fields. But there is an exception for types that are either a subtype or
supertype of the given class, because these types are not included in the
calculated CBO value.

Excessive coupled classes prevent reuse of existing components and they are
damaging for a modular, encapsulated software design. To improve the
modularity of a software the inter coupling between different classes should
be kept to a minimum. Beside reusability a high coupling has a second
drawback, a class that is coupled to other classes is sensitive to changes in
that classes and as a result it becomes more difficult to maintain and gets
more error-prone. Additionally it is harder to test a heavly coupled class in
isolation and it is harder to understand such a class. Therefore you should
keep the number of dependencies at a minimum.

Thresholds

Based on their research Sahraoui, Godin and Miceli [2]
suggest a maximum CBO value of 14, because higher values
have negative impacts on several quality aspects of a class, which includes
the maintainability, stability and understandability.

E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To leave a comment you must approve it via e-mail, which will be sent to your address after submission.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.Enter the string from the spam-prevention image above:

Remember Information? Subscribe to this entry

Submitted comments will be subject to moderation before being displayed.