Thursday, March 02, 2006

Hint: A 79 Cyclomatic Complexity Score is Not Good

I don’t mean to pick on DotNetNuke, but there’s a reason to run metrics checkers on your code.  There’s a reason to avoid having single methods with 432 lines of code.  There’s a reason to avoid having methods with cyclomatic complexity scores of 79.  There’s a reason to avoid methods with a Maintenance Complexity measurement of 3,176.  There’s a reason to review and refactor code, somehow, anyhow, to avoid this kind of stuff.

I’ve got one method in NUGSoft which has a CC of 26 or something, but that’s a comparison method for a moderately complex business entity and it’s stuffed with a bunch of statements like if (left.FName != right.FName) return false;, so there are a passle of paths and conditioinals in it.  (That pattern is straight out of Wagner’s book, so don’t give me grief, either!)

(The shiny toy is CR_Metrics from CR_Plugin, a DxCore plugin.)


Chris said...

I was wondering if you have been able to compile the plug-in in VS 2005. I have not been able to do so and I am not familiar with the DX Core library to rework the code to get it to compile.

Chris Hoffman

Jim Holmes said...

I cheated, Chris -- I had an older version of DxCore which works with the SourceForge version of CR_Plugin.

I contacted the folks at DevExpress to see what the deal was. They're updating their next release of DxCore to fix the issue. Look for that maintenance release of DxCore to be out in a week or two.

Chris said...

Thanks Jim, I will keep my eye out for the update. I was really looking forward to getting some metrics on my code and the screen shot looks like this is going to be a great asset.


Subscribe (RSS)

The Leadership Journey