Slide 12
Slide 12 text
OO Metrics - Cohesion and Coupling
Consider a class C with n methods M1, M2..., Mn. Let {Ij} = set of instance
variables used by method Mi.
There are n such sets I1 ,…, In
• P = {(Ii, Ij) | (Ii ∩ Ij ) = ∅}
• Q = {(Ii, Ij) | (Ii ∩ Ij ) ≠ ∅}
LCOM = |P| - |Q|, if |P| > |Q|
= 0, otherwise
• High LCOM indicate the violation of the Single Responsibility Principle.
LCOM Lack of Cohesion
Of Methods