|
The intuition behind the Chidamber and Kemerer metric is to inspect pairs of
methods. If there are many pairs that access the same data, then the class is
cohesive. On the other hand, if there are many pairs that do not access any
common data, then the class is not cohesive.
In the Chidamber and Kemerer method, this is measured as follows:
- n1 = number of pairs of distinct methods in a reftype that do
not
have at least one commonly accessed field
- n2 = number of pairs of distinct methods in a reftype that do
have at least one commonly accessed field
- LCOM = ((n1 - n2)/2 max 0)
We divide by 2 because each ordered pair (m1,m2) is counted twice in n1 and n2.
High values of LCOM indicate a lack of cohesion. Specifically,
an LCOM of greater than 500 indicates a potential problem.
References
Victor Basili,
Lionel Brand and
Walcelio Melo.
A validation of object-oriented design metrics as quality indicators.
IEEE Transactions on Software Engineering, Volume 22, No. 10, pages 751-760. October 1996.
Shyam R. Chidamber and
Chris F. Kemerer.
A Metrics Suite for Object Oriented Design
.
IEEE Transactions on Software Engineering,
20(6), pages 476-493, June 1994.
David P. Darcy,
Sandra A. Slaughter,
Chris F. Kemerer,
James E. Tomayko.
The Structural Complexity of Software: An Experimental Test
.
IEEE Transactions on Software Engineering, 31(11), pages 982--995, 2005.
Diomides D. Spinnelis.
Code Quality: The Open Source Perspective.
Addison-Wesley 2007.
Diomides D. Spinnelis.
ckjm - Chidamber and Kemerer Java Metrics.
(implementation of CK metrics), 2006.
|