For the unenlightened: cyclomatic complexity on WikiPedia.
I remember having this conversation with a coworker a while ago, and I was recently reminded of it. Cyclomatic complexity is never a useful metric. There are two scenarios:
- You're not very good at programming.
- You're good at programming
In the first scenario, you're an idiot. You are mostly incapable of recognizing good code from bad code, let alone understanding the complexity of cyclomatic complexity, which isn't really t hat complex (this sentence is awesome). To you, a giant switch statement or 12 nested if statements is not a red flag. Seeing a high number next to "CC" is not going to give you cause for alarm. You will blissfully ignore it and continue writing code that doesn't escape user input in a dynamic SQL statement.
In the second scenario, you're not an idiot. You can recognize good code from bad code, and you understand that high cyclomatic complexity is caused by many branches in the code. Furthermore, you'll also know that giant switch statements are generally bad, and you've probably never written nested if statements to a depth greater than 2. You know what you're doing. Therefore, all code you write will be cyclomatically simple by default, because that's your natural style of writing code. If you do happen to write a function that has many branches, it will be for a reason. Because, you know, you're not stupid. Therefore, you will ignore the cyclomatic complexity report because you purposefully wrote the function that way.
So it doesn't matter if you're stupid or smart; good or bad; experience or inexperienced; cyclomatic complexity will never matter to you.