-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Sonar Code Quality Testing Essentials
By :

The Lack of Cohesion in Methods (LCOM) metric measures the cohesion of a class and it was first introduced in the Chidamber & Kemerer metrics suite in 1993. Since then, the metric was redefined and revised numerous times, with LCOM5 being the latest version.
Sonar incorporates version four of the metric, hence the LCOM4 naming. The metric measures the degree to which methods and fields within a class are related to one another, providing one or more components. To calculate the LCOM4 value, we have to determine how many connected groups of related methods and fields exist in a class:
LCOM4 = 1
: The class is a solid component with all methods and fields related
LCOM4 > 1
: The class can be split to different classes
LCOM4 = 0
: The class has no methods
According to the single responsibility principle, a class should provide a single component with all methods and fields related. This is the case when LCOM4 = 1
. Otherwise, the class lacks...
Change the font size
Change margin width
Change background colour