Detail about cyclomatic complexity, formula to measure cyclomatic complexity and how this metric useful in software testing and uses of cyclomatic complexity etc.
Overview..
What is Software Design?
Software Metrics.
Complexity.
Cyclomatic Complexity.
Example.
Determine Cyclometic Complexity.
How this metrics is useful for software Testing?
Uses of Cyclometic Complexity.
Conclusion.
What is a Software Design?
SoftwareDesignisaprocessto
transformuserrequirementsinto
somesuitableformwhichhelpsthe
programmerinsoftwarecodingand
implementation.
Cyclometic Complexity..
Aprogramconsistsofstatements.
Someofthemaredecisionmakingwhichchange
theflowofprogram.
DevelopedbyMcCabe,in1976.
Measures the number of linearly independent
paths through a program.
LowertheProgram'scyclomaticcomplexity,
lowertherisktomodifyandeasiertounderstand.
Example..
Cyclometic Complexity = Edges –Nodes + 2P
P= Number of unconnected parts of the graph.
Another Example..
[1—2—6]
[1—2—3—5—2—6]
[1—2—3—4—5—2—6]
Cyclomatic Complexity
= 7 -6 + 2*1 = 3
In this Example:-
Cont..
Cyclomatic Complexity
= 7 -8 + 2*2 = 3
In this Example:-
Cont..
Cyclomatic Complexity
= 2 + 1 = 3
In this Example:-
Cyclomatic complexity= Number of Predicate
Nodes + 1
Cont..
Cyclomatic Complexity
= 3
In this Example:-
Cyclomatic complexity = number of regions in
the control flow graph.
How this metric is useful
for software testing..
BasisPathtestingisoneofWhiteboxtechnique
anditguaranteestoexecuteatleastonestatement
duringtesting.
Itcheckseachlinearlyindependentpaththrough
theprogram.
Conclusion..
It is mainly used to evaluate complexity of a
program.
If the decision points are more, then complexity
of the program is more.
If program has high complexity number, then
probability of error is high with increased time for
maintenance and trouble shoot.