ObjectOriented Metrics: LCOM
LCOM (Lack of Cohesion of Methods) as revised by Brian HendersonSellers
in [HEN96]
CK originally proposed LCOM
Chidamber & Kemerer proposed the original LCOM Lack of Cohesion
metric in [CHI94]
Given n methods M_{1}, M_{2}, …,
M_{n} contained in a class C_{1} which
also contains a set of instance variables {I_{i}} . Then
for any method M_{i} we can define the partitioned set of
P = {(I_{i}, I_{j})  I_{i} ∩ I_{j}
= φ} and Q = {(I_{i}, I_{j})  I_{i} ∩ I_{j}
≠ φ}
then LCOM = P  Q, if P > Q
=0 otherwise
LCOM is a count of the number of method pairs whose similarity
is zero.
CK example from [HEN96] LCOM as defined above
Based on M's as methods and A's as instance variables both of the above
graphs of classes derive an LCOM measure of 8.
However it seems clear that the graph on the right is a lot more
intuitively cohesive.
HendersonSellers revised LCOM^{*}
HendersonSellers revises the LCOM metric to normalise it for the number
of methods and variables that rae present in the class:
Where the number of methods is m and the number of instance variables
( attributes) a set of {A_{j}} (j=1,
2, …, a). Let μ(A_{j}) be the number of methods which
access each datum.
With this new measure the mteric is simplified an normalised.
References

[CHI94] Chidamber, S., R., Kemerer, C., K., A Metrics Suite for Object
Oriented Design, IEEE Trans. on Software Eng., Vol.20, No.6, June
1994.

[HEN 96] HendersonSellers, B., Objectoriented metrics : measures of
complexity, PrenticeHall, pp.142147, 1996.