Cyclomatic complexity yields a value to your Software – Know how.
Developed by Thomas J. McCabe, Sr. in 1976, Cyclomatic complexity is a software metric (measurement), used to indicate the complexity of a program. It is a quantitative measure of the number of linearly independent paths through a program’s source code.
The more the cyclomatic complexity, the more complex is the lines of code that you have written.
Cyclomatic Complexity is directly related to the health of the code!
Cyclomatic complexity is measured based on the numbers given per method in the source code. It is a direct function of the number of branches in your program. With each if, for, or case, you add to the cyclomatic complexity of the program. By removing branching from a function, you can make it less complex.
The lines of code in a class or a method also affects the cyclomatic complexity, a greater number of lines means, a combination of several logic altogether, which clearly violates SRP (Single responsibility principle).
High “complexity” is directly translated to low readability and high maintenance costs.
There probably is no single simple measurement that can express an abstract concept such as complexity in a single number. But this does not imply that we cannot measure and control complexity. It just has to be done with multiple metrics and checks that cover the various aspects of complexity.
Horus, an engineering management platform, with a set of metrics helps measure these factors and track the health score of the application. Head over to explore Horus
Learn more about Horus in the previous article