Member predicate MetricPackage::MetricPackage::relationalCohesion

Relational Cohesion.

Relational Cohesion measures how well a package p hangs together. That is, for each type in p we measure how many types within p it depends on, and we take the average. To cater for the case that there is only one type in the package (and then obviously the package is quite cohesive!) we add 1 to the resulting average.

The recommended range for this metric is between 1.5 and 4.0: too low a cohesion indicates that the package is a “kitchen sink” containing too many unrelated types. On the other hand, a cohesion that is too high indicates a package that is too complex, with too many internal dependencies.

Note: some tools compute this metric not by counting types, but by counting the different ways one type depends on another. While this is appropriate in a tool that distinguishes between associations, generalizations and use links, it is less appropriate for metrics that are directly computed from code.

float relationalCohesion()