Total Correlation

This definition of Lack of Cohesion use Watanabe's (1960) generalisation of mutual information known as Total Correlation, which determines if a group of variables exhibit redundancy or structure.

Its application to the measurement of cohesion is simple. Each method in a class makes use of a subset of the fields of the class. We want to know whether these subsets exhibit some structure in the pattern of field usage. If such a structure exists then it can be extracted into one or more other classes in order to remove or reduce the structure. We may therefore consider the use of each field by the methods as a 'random' binary variable with a certain probability of occurrence. The rest follows naturally from the definition of Total Correlation.

Although removal of structure would normally be considered a bad thing in software, the ideal cohesive scenario of 'all fields used by all methods' exhibits no structure in field usage.


Note 1: I have only included methods if they access at least one field.

Note 2: I have only included fields if they are accessed by at least one method in the class.


This plugin is provided by State Of Flow