Raymond Lewallen

Sponsors

The Lounge

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
My Cyclomatic Complexity Thresholds

When anaylizing some cyclomatic complexity (measures the number of linearly-independent paths through a program module), I was thinking to myself about where I want my thresholds to be.  Where to I say “this is simple enough” or “I definately need to refactor this”.

So here is my conclusion:

  • 1–10  Simple enough.  Don’t change.  Little risk involved.
  • 11–20  Should consider refactoring.  Moderate risk involved.
  • 21–40  Definate refactoring needed here.  Risk is too high.
  • > 41  What was I thinking?  Throw this away and start over.

I won’t find anything in the greater than 41 range, but if I were to find anything, I’d definately throw it away.


Posted Mon, Jun 13 2005 6:38 AM by Raymond Lewallen

[Advertisement]

Comments

Eric Marthinsen wrote re: My Cyclomatic Complexity Thresholds
on Mon, Jun 13 2005 8:02 AM
Are there any solid tool for doing source code analysis of .NET programs?
Sahil Malik wrote re: My Cyclomatic Complexity Thresholds
on Mon, Jun 13 2005 8:19 AM
Raymond Lewallen wrote re: My Cyclomatic Complexity Thresholds
on Mon, Jun 13 2005 8:27 AM
I posted this before I saw Sahil's comment, but here is a link to some tools I use: http://www.codebetter.com/blogs/raymond.lewallen/archive/2005/06/13/64539.aspx
Jeremy D. Miller -- The Shade Tree Developer wrote Best and Worst Practices for Mock Objects
on Tue, Jan 10 2006 6:01 PM
Mock objects are like any other tool.  Used one way they’re a huge time saver.  In other cases...
David M. Kean wrote re: My Cyclomatic Complexity Thresholds
on Fri, Mar 3 2006 11:00 PM
Have a look at FxCop or the Managed Code Analysis in Team System.

Doesn't analyze source code but rather the binary and also does CCC (Team System version only).
Josh Adams wrote re: My Cyclomatic Complexity Thresholds
on Tue, Jun 12 2007 10:35 AM
Raymond, I was just blogging about this topic: http://devreflection.wordpress.com/2007/06/11/cyclomatic-complexity-and-refactoring/ Do you have any suggestions for the scenario I describe in the post (specifically I've got a class that's a concrete implementation of System.Xml.XPath.XmlNavigator--lots of abstract methods are defined on that class ;( )?

Add a Comment

(required)  
(optional)
(required)  
Remember Me?