The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Analizo::Metric::LackOfCohesionOfMethods - Lack of Cohesion of Methods (LCOM4) metric

DESCRIPTION

The metric calculation is based on the following article and calculates the cohesion of the class.

Article: Comparison of Various Lacks of Cohesion Metrics by Taranjeet Kaur and Rupinder Kaur.

See the paragraphs about Lack of Cohesion of Methods LCOM4 in the article:

LCOM3 varies in range between [0, 1]. LCOM3 indicates high cohesion and it is also a well defined class, it show simplicity of class and high reusability of class. A highly cohesive class provides high degree of encapsulation. LCOM3 formula is

  M: number of methods in a class
  A: number of variables in a class
  m.A: number of methods that access a variable
  Sum(m.A): number of methods over attributes
  a: variabes that shared may be or not

  LCOM3=(m - Sum(mA) / a) / m - 1

In other words also say that consider connected components of graph or also say that if we consider undirected graph G where vertices are methods of a class and edge between vertices if corresponding methods at least share one instance variable.

LCOM4 is like LCOM3 where graph G additionally has an edge between vertices representing methods Mi and Mj if Mi invokes Mj. In other words also say that, it measure number of components in a class. A connected component is a set of related methods.