Lack of Cohesion of Methods of a Type (Henderson-Sellers) |
|
The intuition underlying the Henderson-Sellers method of calculating Lack of Cohesion of Methods (LCOM) is that in a cohesive class C, many methods access the same fields of C. Formally, let
- M = set of methods in class
- F = set of fields in class
- r(f) = number of methods that access field f
- ar = mean of r(f) over f in F
We then define LCOM of the class under consideration to be
LCOM = (ar - |M|) / (1 - |M|)
We follow Lance Walton (author of the State of Flow Eclipse Metrics Plugin) in restricting M to methods that read some field in the same class, and F to fields that are read by some method in the same class.
A value greater than 0.9 indicates a class that may deserve some further
scrutiny.
References
Brian Henderson-Sellers.
Object-Oriented Metrics: Measures of Complexity.
Prentice-Hall 1996.
Frank Sauer.
Metrics 1.3.6 - Getting Started.
2005.
Renaat Verbruggen. Object-oriented patterns and metrics (Lecture Notes). (updated regularly)
Lance Walton.
Eclipse Metrics Plugin.
State of Flow, 2005.
|