Edit: I originally wrote this post for the NDepend blog. You can check out the original here, at their site. While you’re there, download NDepend and give it a try. If you like static analysis, you’ll find yourself hooked.
One of the things that has surprised me over the years is how infrequently people take advantage of customizable code metrics. I say this not from the perspective of a geek with esoteric interest in a subject, wishing other people would share my interest. Rather, I say this from the perspective of a business man, making money, and wondering why I seem to have little competition.
As I’ve mentioned before, a segment of my consulting practice involves strategic code assessments that serve organizations in a number of ways. When I do this, the absolute most important differentiator is my ability to tailor metrics to the client and specific codebases on the fly. Anyone can walk in, install a tool, and say, “yep, your cyclomatic complexity in this class is too high, as evidenced by this tool I installed saying ‘your cyclomatic complexity in this class is too high.'” Not just anyone can come in and identify client-specific idiosyncrasies and back those findings with tangible data.
But, if they would invest some up-front learning time in how to create custom code metrics, they’d be a lot closer.
Being able to customize code metrics allows you to reason about code quality in very dynamic and targeted terms, and that’s valuable. But you might think that, unless you want a career in code base assessment, that value doesn’t apply to you. Let me assure you that it does, albeit not in quite as direct way as it applies to me.
Custom code metrics can help make your team better, and they can do so in a variety of ways. Let’s take a look at a few.