Grax Coding

Saturday, April 12, 2014

Get Rid of Bad Code once and for all with nDepend 5

What is nDepend?

nDepend is a tool used for analyzing a .NET code base.  It can find issues, track metrics, and create reports.

nDepend version 5

What I like

nDepend comes with a lot of rules for analyzing your code base.  It comes with over 150 rules to check your code against industry best practices.

But I also like that you can easily modify the rules to match your needs.   Each rule is a query that you can modify to suit your needs.  Perhaps you don't agree with a naming convention or your organization has some specific coding standards.  With CQLinq, you can write and enforce your own rules.

Being able to set a baseline and then monitor trends is a great way to set and reach code-quality goals.  If you can express it in a CQLinq query, you can track it.  Over time, you can produce graphs to show management how awesome your refactoring project is going.

I didn't get around to doing this yet, but you can integrate nDepend into your build process.  This should allow you to automatically track metrics over time across your team.

What I don't like (and I'm being nitpicky)

The installation method is different from most other tools I use.  You place nDepend placed in a directory, launch the program, and click on a button to associate with the various Visual Studio versions.  It isn't hard and never failed to work properly for me.  However, I just found it a little unusual compared to other Visual Studio add-ins.

Summary

nDepend is easy to use and powerful.  Within 15 minutes of installing it, I found that someone in my project had written code that incorrectly crossed layers.  I love the Abstractness VS Instability chart.  (More on that here from Scott Hanselman).