Coupling Between Object classes (CBO)
The Coupling Between Object classes metric represents the number of classes coupled to a given class. This coupling can happen throuhg:
- method call
- class extends
- properties or parameters
- method arguments, or return types
- variables in methods
Coupling between classes is required for a system to do useful work, but excessive coupling makes the system more difficult to maitain and reuse.
At project or package level, this metric provides the average number of classes used per class.
A value of 0 indicates that a class has no relationship to any other class in the system, and therefore should not be part of the system.
A value between 1 and 4 is good, since it indicates that the class is loosely coupled.
A number higher than this may indicate that the class if too tightly coupled with other classes in the model, which would complicate testing and modification, and limit the possibilities of re-use. Consider de-coupling this class from the classes to which this class is coupled, and build the class so that it is more independent by providing a more complete set of operations.
Dependencies are not taken into account in the these situations:
- Class is referenced in a symbolic manner; for instance in a $zobj* function or an EXECUTE statement.
- Imports make it ambiguous what class is actually used; for instance, %String and %Library.String are considered different classes even though the %Library namespace is implicitly imported.