next up previous
Next: Improvement of LCOM ( Up: Cohesion Previous: Cohesion


Lack of Cohesion in Methods ($ LCOM$ )

Works with all instances of a common meta-model, regardless of whether they were produced with the Java or the UML front-end. The respective extends (Java) or generalization (UML) relations expressing the inheritance between two classes are mapped onto relations of type inheritance in the common meta-model (and the $ LCOM$specific view).
Handle
$ LCOM$
Description
The Lack of Cohesion in Methods metric is a measure for the number of not connected method pairs in a class representing independent parts having no cohesion. It represents the difference between the number of method pairs not having instance variables in common, and the number of method pairs having common instance variables.
Scope
Class
View
$ {V}^{LCOM} = ({G}^{LCOM}, {R}^{LCOM})$
  • Grammar $ {G}^{LCOM} = (\{\textrm{class}^{LCOM}, \textrm{method}^{LCOM}, \textrm{field}^{LCOM}\}, \emptyset, \\ \textrm{class}^{LCOM})$
  • Relations $ \\ {R}^{LCOM}: \{\textrm{methodof}^{LCOM} : \textrm{method}^{LCOM} \times \tex... ...\\ \textrm{uses}^{LCOM} : \textrm{method}^{LCOM} \times \textrm{field}^{LCOM}\}$
  • Mapping $ \alpha^{LCOM}$:
    $\displaystyle \alpha^{LCOM}(\textrm{Class})$ $\displaystyle \mapsto$ $\displaystyle \textrm{class}^{LCOM}$  
    $\displaystyle \alpha^{LCOM}(\textrm{field})$ $\displaystyle \mapsto$ $\displaystyle \textrm{field}^{LCOM}$  
    $\displaystyle \alpha^{LCOM}(\textrm{Method})$ $\displaystyle \mapsto$ $\displaystyle \textrm{method}^{LCOM}$  
    $\displaystyle \alpha^{LCOM}(\textrm{IsFieldOf})$ $\displaystyle \mapsto$ $\displaystyle \textrm{fieldof}^{LCOM}$  
    $\displaystyle \alpha^{LCOM}(\textrm{IsMethodOf})$ $\displaystyle \mapsto$ $\displaystyle \textrm{methodof}^{LCOM}$  
    $\displaystyle \alpha^{LCOM}(\textrm{Accessess})$ $\displaystyle \mapsto$ $\displaystyle \textrm{uses}^{LCOM}$  

Definition
The $ LCOM$value of a class $ c \in class^{LCOM}$, with $ n$methods $ m_{1}, m_{2}, \dots, m_{n} \in M(c)$, having $ \{I(c, m_{i}) \in F(c)\}$represent the set of instance variables used by method $ m_{i}$- there are $ n$such sets $ \{I_{1}, \dots, I_{n} \in F(c)\}$- is defined as:
$\displaystyle F(c)$ $\displaystyle =$ $\displaystyle pred(c, \textrm{fieldof}^{LCOM})$  
    $\displaystyle \textit{-\hspace{1pt}- set of fields contained in c}$  
$\displaystyle M(c)$ $\displaystyle =$ $\displaystyle pred(c, \textrm{methodof}^{LCOM})$  
    $\displaystyle \textit{-\hspace{1pt}- set of methods contained in c}$  
$\displaystyle I(c,m)$ $\displaystyle =$ $\displaystyle succ(m, \textrm{uses}^{LCOM}) \cap F(c)$  
    $\displaystyle \textit{-\hspace{1pt}- set of fields contained in c and used by m}$  
$\displaystyle P(c)$ $\displaystyle =$ $\displaystyle \{(m_{i},m_{j}) \vert m_{i},m_{j} \in M(c) \wedge I(c,m_{i}) \cap I(c,m_{j}) = \emptyset\}$  
    $\displaystyle \textit{-\hspace{1pt}- set of disjunct sets of instant variables of c}$  
$\displaystyle Q(c)$ $\displaystyle =$ $\displaystyle \{(m_{i},m_{j}) \vert m_{i},m_{j} \in M(c) \wedge I(c,m_{i}) \cap I(c,m_{j}) \neq \emptyset\}$  
    $\displaystyle \textit{-\hspace{1pt}- set of conjunct sets of instant variables of c}$  
$\displaystyle LCOM(c)$ $\displaystyle =$ \begin{displaymath}\left\{ \begin{array}{ll} \left\vert P(c)\right\vert-\left\ve... ...ft\vert Q(c)\right\vert \ 0 & otherwise\ \end{array}\right.\end{displaymath}  

Scale
Absolute.
Domain
Integers $ \in 0..\infty$.
Highly Related Software Quality Properties
 
Reliability 2.2
is positively influenced by cohesion.
Maturity 2.2.1:
Parts of a system showing a high cohesion may be highly directly related to maturity, since a mature system ought to have high cohesion values.

Maturity decreases with increasing LCOM.

Re-Usability 2.4
is negatively influenced by coupling.
Understandability for Reuse 2.4.1:
Parts of a system showing a high cohesion may be highly directly related to understandability for reuse, since they implement only one concept.

Understandability decreases with increasing LCOM.

Attractiveness 2.4.4:
Parts of a system showing a high cohesion may be highly directly related to attractiveness for reuse, since they implement only one concept.

Attractiveness decreases with increasing LCOM.

Maintainability 2.6
decreases with increasing LCOM.
Analyzability 2.6.1:
Parts of a system showing a high cohesion may be highly directly related to analyzability, since they implement only one concept.

Analyzability decreases with increasing LCOM.

Changeability 2.6.2:
Parts of a system showing a high cohesion may be highly directly related to changeability, since they implement only one concept.

Changeability decreases with increasing LCOM.

Stability 2.6.3:
Parts of a system showing a high cohesion may be highly directly related to stability, since they implement only one concept.

Stability decreases with increasing LCOM.

Testability 2.6.4:
Parts of a system showing a high cohesion may be highly directly related to testability, since they implement only one concept.

Testability decreases with increasing LCOM.

Portability 2.7
decreases with increasing LCOM.
Adaptability 2.7.1:
Parts of a system showing a high cohesion may be highly directly related to adaptability, since they implement only one concept.

Adaptability decreases with increasing LCOM.

Related Software Quality Properties
 
Re-Usability 2.4
might decrease with increasing LCOM.
Learnability for Reuse 2.4.2:
Parts of a system showing a high cohesion may be highly directly related to learnability, since they implement only one concept.

Learnability might decrease with increasing LCOM.

Operability for Reuse - Programmability 2.4.3:
Parts of a system showing a high cohesion may be highly directly related to programmability, since they implement only one concept.

Programmability might decrease with increasing LCOM.

Efficiency 2.5
might decrease with increasing LCOM.
Time Behavior 2.5.1:
Parts of a system showing a high cohesion may be directly related to time behavior, since they implement only one concept, and do not do any unrelated time consuming tasks.

Time behavior might get worse with increasing LCOM.

Resource Utilization 2.5.2:
Parts of a system showing a high cohesion may be directly related to resource utilization, since they implement only one concept, and do not do any unrelated resource utilization.

Resource utilization might get worse with increasing LCOM.

Portability 2.7
decreases with increasing LCOM.
Replaceablity 2.7.4:
Parts of a system showing a high cohesion may be directly related to replaceability, since they implement only one concept.

Replaceablity might decreases with increasing LCOM.

References
 
  • LCOM is extensively discussed and evaluated in [5,6,14,3,2,1,7,11,12,10,4,21,17,19],
  • LCOM is implemented in the VizzAnalyzer Metrics Suite.
Since
1.0

next up previous
Next: Improvement of LCOM ( Up: Cohesion Previous: Cohesion
Copyright © 2008-2009, ARiSA AB. Phone: +46-(0)470 70 8495 Email: info@arisa.se Valid CSS! Valid XHTML 1.0 Transitional