next up previous
Next: Weighted Method Count ( Up: Structural Complexity Previous: Structural Complexity


McCabe Cyclomatic Complexity ($ CC$ )

$ CC$can be computed on instances of a common meta-model, as long as the required types are provided by the front-end. A UML front-end, e.g., would not construct nodes of required type. Still, this front-end works with the new meta-model and the metric is unambiguously defined.
Description
$ CC$is a measure of the control structure complexity of software. It is the number of linearly independent paths and therefore, the minimum number of independent paths when executing the software.
Scope
Method
View
$ {V}^{CC} = ({G}^{CC}, \emptyset).$
  • Grammar $ {G}^{CC} = ({T}^{CC}, {P}^{CC}, {\textrm{method}}^{CC})$
  • Entities $ {T}^{CC} = \{{\textrm{method}}^{CC}, {\textrm{ctrl\_stmt}}^{CC} \}$
  • Productions $ {P}^{CC}$:
    $\displaystyle {\textrm{method}}^{CC}$ $\displaystyle =$ $\displaystyle {\textrm{ctrl\_stmt}}^{CC\ *}$  
    $\displaystyle {\textrm{ctrl\_stmt}}^{CC}$ $\displaystyle =$ $\displaystyle {\textrm{ctrl\_stmt}}^{CC\ *}$  

  • Mapping $ \alpha^{CC}$:
    $\displaystyle \alpha^{CC}(\textrm{Method})$ $\displaystyle \mapsto$ $\displaystyle method^{CC}$  
    $\displaystyle \alpha^{CC}(\textrm{Switch})$ $\displaystyle \mapsto$ $\displaystyle \textrm{ctrl\_stmt}^{CC}$  
    $\displaystyle \alpha^{CC}(\textrm{Loop})$ $\displaystyle \mapsto$ $\displaystyle \textrm{ctrl\_stmt}^{CC}$  

Definition
The $ CC$value of a method $ m \in method^{CC}$is defined as:

$\displaystyle CC(m) := \left\vert succ^+\left(m, \textrm{contains}^{CC} \right)\right\vert + 1$
Scale
Absolute.
Domain
Integers in $ 1..\infty$.
Highly Related Software Quality Properties
 
Re-Usability 2.4
is both negatively and positively influenced by attributed assess with Cyclomatic Complexity.
Understandability for Reuse 2.4.1:
Understanding if a class is suitable for reuse depends on its complexity.

Understandability declines with increasing Cyclomatic Complexity.

Learnability for Reuse 2.4.2:
Learning if a class is suitable for reuse depends on the complexity of its interface. Systems with high control complexity may also have a complex (behavioral) interface.

Learnability declines with increasing Cyclomatic Complexity.

Operability for Reuse - Programmability 2.4.3:
How well a class can be integrated depends the complexity of its interface. Systems with high control complexity may also have a complex (behavioral) interface.

Programmability declines with increasing Cyclomatic Complexity.

Attractiveness 2.4.4:
Attractiveness of a class depends on the complexity of the potentially reused code. Cyclomatic Complexity allows an assessment complexity.

Attractiveness increases with increasing Cyclomatic Complexity.

Maintainability 2.6
declines with increasing Cyclomatic Complexity.
Analyzability 2.6.1:
The effort and time for diagnosis of deficiencies or causes of failures, or for identification of parts to be modified is directly related to the number of execution paths, i.e. the complexity of the control flow.

Analyzability declines with increasing Cyclomatic Complexity.

Changeability 2.6.2:
Each modification must be correct for all execution paths. Cyclomatic Complexity computes the number of the linearly independent paths, a lower bound of all execution paths ignoring multiple iterations.

Changeability declines with increasing Cyclomatic Complexity.

Testability 2.6.4:
Complete testing requires coverage of all execution paths. Cyclomatic Complexity computes the number of the linearly independent paths, a lower bound of all execution paths ignoring multiple iterations.

Testability declines with increasing Cyclomatic Complexity.

Portability 2.7
declines with increasing Cyclomatic Complexity.
Adaptability 2.7.1:
As for changeability 2.6.2, the complexity the control structure of software has a direct impact. Each modification must be correct for all execution paths. Cyclomatic Complexity computes the number of the linearly independent paths, a lower bound of all execution paths ignoring multiple iterations.

Adaptability declines with increasing Cyclomatic Complexity.

Replaceablity 2.7.4:
The substitute of a component must imitate its observable behavior. Components with complex control structures might have a more complex observable behavior making it more difficult to check substitutability and to actually substitute a component.

Replaceablity declines with increasing Cyclomatic Complexity.

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

Interoperability might increase with increasing $ CC$ .

Security 2.1.4:
Relating Cyclomatic Complexity to security requires to be able to locate the parts of a system responsible for security. Complexity in these parts might indicate a higher security.

Security might increase with increasing Cyclomatic Complexity.

Reliability 2.2
might increase with increasing Cyclomatic Complexity.
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 control-flow complexity.

Maturity might decline with increasing Cyclomatic Complexity.

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

Fault-Tolerance might increase with increasing $ CC$ .

Recoverability 2.2.3:
Relating Cyclomatic Complexity to recoverability requires to be able to locate the parts of a system responsible for recoverability. Complexity in these parts might indicate a higher recoverability.

Recoverability might increase with increasing $ CC$ .

Efficiency 2.5
might decline with increasing Cyclomatic Complexity.
Time Behavior 2.5.1:
Static complexity might indicate a higher execution complexity.

Time behavior might get worse with increasing Cyclomatic Complexity.

Maintainability 2.6
declines with increasing Cyclomatic Complexity.
Stability 2.6.3:
Due to reduced analyzability 2.6.1 and testability 2.6.4, also stability may be influenced negatively by control-flow complexity.

Stability might decline with increasing Cyclomatic Complexity.

References
 
Since
Compendium 1.0

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