next up previous
Next: Response For a Class Up: Structural Complexity Previous: McCabe Cyclomatic Complexity (


Weighted Method Count ($ WMC$ )

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 $ WMC$specific view).
Handle
$ WMC$
Description
A weighted sum of methods implemented within a class. It is parameterized by a way to compute the weight of each method. Possible weight metrics are:
  • McCabe Cyclomatic Complexity 3.1.3,
  • Lines of Code 3.1.1,
  • 1 (unweighted WMC).
This variant of $ WMC$uses McCabe Cyclomatic Complexity 3.1.3 metric for calculating the weight for each method. Originally defined as an object-oriented metric, it can easily adapted to non-object-oriented systems computing the weighted sum of functions implemented within a module or file.
Scope
Class
View
$ {V}^{WMC} = ({G}^{WMC}, {R}^{WMC})$
  • Grammar $ {G}^{WMC} = (\{\textrm{class}^{WMC}, \textrm{method}^{WMC}\}, \emptyset, \textrm{class}^{WMC})$
  • Relations $ {R}^{WMC}: \{\textrm{methodof}^{WMC} : \textrm{method}^{WMC} \times \textrm{class}^{WMC}\}$
  • Mapping $ \alpha^{WMC}$:
    $\displaystyle \alpha^{WMC}(\textrm{Class})$ $\displaystyle \mapsto$ $\displaystyle \textrm{class}^{WMC}$  
    $\displaystyle \alpha^{WMC}(\textrm{IsMethodOf})$ $\displaystyle \mapsto$ $\displaystyle \textrm{methodof}^{WMC}$  
    $\displaystyle \alpha^{WMC}(\textrm{Method})$ $\displaystyle \mapsto$ $\displaystyle \textrm{method}^{WMC}$  

Definition
The $ WMC$value of a class $ c \in class^{WMC}$is defined as:
$\displaystyle M(c)$ $\displaystyle =$ $\displaystyle pred(c, \textrm{methodof}^{WMC})$  
    $\displaystyle \textit{-\hspace{1pt}- set of methods directly contained in c}$  
$\displaystyle WMC(c)$ $\displaystyle =$ $\displaystyle \sum_{m \in M(c)} CC(m)$  

Scale
Absolute.
Domain
Integers $ \in 0..\infty$.
Highly Related Software Quality Properties
 
Re-Usability 2.4
depends on the weight metric, which influences the attributes assessed with WMC negatively or positively.

Re-Usability declines with increasing unweighted WMC.

Understandability for Reuse 2.4.1:
Understanding if a class is suitable for reuse depends on the size of its interface.

Understandability declines with increasing unweighted WMC.

Learnability for Reuse 2.4.2:
Learning if a class is suitable for reuse depends on the size of its interface.

Learnability declines with increasing unweighted WMC.

Operability for Reuse - Programmability 2.4.3:
How well a class can be integrated depends on the size of its interface.

Programmability declines with increasing unweighted WMC.

Attractiveness 2.4.4:
Attractiveness of a class depends on the size and complexity of the potentially reused code. Depending on the weight metric, WMC allows an assessment of size or complexity.

Attractiveness increases with increasing unweighted WMC.

Maintainability 2.6
declines with increasing WMC.
Analyzability 2.6.1:
The effort and time for diagnosis of deficiencies or causes of failures in a class, or for identification of parts to be modified is directly related to the size and complexity of the class. Depending on the weight metric, WMC allows an assessment of size or complexity.

Analyzability declines with increasing unweighted WMC.

Changeability 2.6.2:
Changing a class requires prior understanding, which, in turn, is more complicated for large and complex systems. Depending on the weight metric, WMC allows an assessment of size or complexity.

Changeability declines with increasing unweighted WMC.

Testability 2.6.4:
Complete testing requires coverage of all execution paths. The number of possible execution paths of a class increases with the number of methods and their control flow complexity. Depending on the weight metric, WMC allows an assessment of the number of methods and their complexity.

Testability declines with increasing unweighted WMC.

Portability 2.7
declines with increasing WMC.
Adaptability 2.7.1:
As for changeability 2.6.2, the size of software has a direct impact. Each modification requires understanding which is more complicated for large systems. Size is specifically assessed by the weighted versions of WMC.

Adaptability declines with increasing unweighted WMC.

Replaceablity 2.7.4:
The substitute of a component must imitate its interface. Large interfaces are difficult to check for substitutability and to actually substitute. Interface size is specifically assessed by the unweighted WMC.

Replaceablity decline with increasing unweighted WMC.

Related Software Quality Properties
 
Functionality 2.1
might increase with increasing WMC.
Interoperability 2.1.3:
Interoperability requires to be able to locate the parts of a system responsible for interoperability. The size of in these parts might indicate a better ability to interact.

Interoperability might increase if the unweighted WMC increases.

Security 2.1.4:
Relating WMC to security requires to be able to locate the parts of a system responsible for security. The size of these parts might indicate a higher security.

Security might increase with increasing unweighted WMC.

Reliability 2.2
might increase with increasing WMC.
Maturity 2.2.1:
Due to reduced analyzability 2.6.1 and testability 2.6.4, bugs mights be left in the software. Therefore, also maturity may be influenced negatively by WMC.

Maturity might decline with increasing unweighted WMC.

Fault-tolerance 2.2.2:
Relating WMC to fault-tolerance requires to be able to locate the parts of a system responsible for fault-tolerance. The size of these parts might indicate a better ability to interact.

Fault-tolerance might increase if the unweighted WMC increases.

Recoverability 2.2.3:
Relating WMC to recoverability requires to be able to locate the parts of a system responsible for recoverability. The size of these parts might indicate a higher recoverability.

Recoverability might increase if the unweighted WMC increases.

Efficiency 2.5
might decline with increasing WMC.
Time Behavior 2.5.1:
Static size might indicate a higher execution time due to increased number of instruction cache misses, long jumps, etc.

Time behavior might get worse with increasing unweighted WMC.

Resource Utilization 2.5.2:
Static size might indicate a higher memory utilization.

Resource utilization might get worse if the unweighted WMC increases.

Maintainability 2.6
declines with increasing WMC.
Stability 2.6.3:
Due to reduced analyzability 2.6.1 and testability 2.6.4, also stability may be influenced negatively by size.

Stability might decline with increasing unweighted WMC.

References
 
  • WMC is extensively discussed in [5,6,14,21,3,2,1,7,11,12,17,4,10],
  • Li and Henry [15] propose to weight the methods according to Cyclomatic Complexity 3.1.3,
  • it is evaluated in a case study [19],
  • WMC is implemented in the VizzAnalyzer Metrics Suite.
Since
Compendium 1.0

next up previous
Next: Response For a Class Up: Structural Complexity Previous: McCabe Cyclomatic Complexity (
Copyright © 2008-2009, ARiSA AB. Phone: +46-(0)470 70 8495 Email: info@arisa.se Valid CSS! Valid XHTML 1.0 Transitional