ALMA Software Engineering |
|||||
|
|
Why bother about complexity?The more complex a module is, the more likely it is to contain errors, and the more difficult it is to test. The more complex it is, the harder it is to maintain. The more it contains errors, the more it needs to be maintained. The problem feeds itself! Some algorithms are complex, regardless of the way they are implemented, but in most cases complex implementation is due to bad design.
o McCabe metrics: V(g) Cyclomatic number (control flow complexity)Notice though, that the cyclomatic complexity is a measure of the program's control complexity and not the data complexity. Furthermore, the same weight is placed on nested and non-nested loops. However, deeply nested conditional structures are harder to understand than non-nested structures.
o Halstead's software science metrics: V Program volume or information content B Estimated number of bugs T Implementation time (or time to understand) D Difficulty level, error proneness E Effort to implement L Program level N Program length, N1 Number of operators N2 Number of operands n Vocabulary size n1 Number of unique operators n2 Number of unique operandsSome notes on CMTJava:
Example of Complexity Computation
|