News Archive
PhpRiot Newsletter
Your Email Address:

More information

A brief introduction to the Coupling Between Objects metric

Note: This article was originally published at Planet PHP on 15 March 2011.
Planet PHP

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.


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.

See also Efferent Coupling: Efferent Coupling or CE is a different name for the same metric, that is frequently used in the literatur. Afferent Coupling: The Afferent Coupling or CA is a metric that calculates the reverse coupling of a class.Bibliography [1]

IEEE Transactions on Software Engineering; A Metrics Suite for Object Oriented Design; Chidamber & Kemerer, 1994


Software Maintenance, 2000. Proceedings. International Conference; Can metrics help to bridge the gap between the improvement of OO design quality and its automation?; Sahraoui, Godin, Miceli; 2000