Code Improvement Through Cyclomatic Complexity
Subject:   code complexity
Date:   2004-06-19 18:09:42
From:   aglover
Response to: code complexity

Cyclomatic Complexity, like most metrics, is merely a guide. A 200 line method, foo, would most likely be flagged with elevated complexity; however, if you pushed that code into 25 separate methods, you have, in effect, lowered foo's complexity and pushed that complexity into succinct methods, which are most likely far easier to isolate and consequently, test. The key point, however, is that those separate calls to 25 methods do not increase the value of Cyclomatic Complexity for method foo. The point assigned in Cyclomatic Complexity for foo is for entering foo, not for foo calling other methods. If foo had a Cyclomatic Complexity of x and called 25 methods, if one added 25 additional calls to methods (and didn't add any conditionals) foo's value is still x.