NDepend – take high level view at your projects

In order to avoid accusation for doing crypto-advertisement, I honestly admit, that I have received for free professional licence for NDepend (worth EUR 299) from Patrick Smacchia (dev lead and inventor of the tool).

It’s kind of weird – I knew about the tool for some time, I even once downloaded its free version, but I got lost when I saw its interface and I didn’t actually play with it much then and I ended up thinking that it’s another crazy/fancy tool for PMs or whoever and I didn’t really see how I might benefit from using it. Then (actually not so long ago) I was listening to one of episodes of my favorite podcast Hanselminutes, and Scott was talking actually whole episode about this tool, and it was then when I realized what it really is about.

It is a really powerful tool, and I’m just diving into it. There are several screencasts that will help you familiarize with it, and I strongly recommend anyone interested in using it to start with screencasts. They are really informative, that is one thing, other is, that user interface in NDepend, is its weakest part. take a look at the screenshot.

ndepend1

You are flooded with information, and unless you know how to look at it, you’ll drown.  It’s simply too much on one screen. You can close some elements to make room for others, but it’s not really a convenient solution. Other really annoying limitation is inability to reorder elements. You only can choose between ordering  Metrics and Dependencies horizontally or vertically. I’d much rather see solution similar to Visual Studio or #Develop, with ability to drag and drop interface elements around, auto-hide them, and ordering with tabs.

Ok, I’ll save more grumbling for the next time. Now let’s move to the nice part that is more important. Ladies and gentlemen I present you CQL.  Truly – that is really wicked idea to query your own code. It’s the single most awesome thing/option/(?)  I have ever seen in a dev tool. And it’s not only something you can use – NDepend uses it internally to gather metrics, and you can open and edit it’s queries, for example:

// <Name>Methods too big (NbLinesOfCode)</Name> 

WARN IF Count > 0 IN SELECT TOP 10 METHODS WHERE NbLinesOfCode > 30

ORDER BY NbLinesOfCode DESC

// METHODS WHERE NbLinesOfCode > 30 are extremely complex and 

// should be split in smaller methods  

// (except if they are automatically generated by a tool).

This gives you names of (at most 10) your methods that have over 30 lines of code, in case of my little project there were three.

ndepend2 

You can see their names, some statistics like, number of IL instructions and get visual indication of (in this case) length of those methods (blue rectangles) compared with other methods in tested assemblies (gray rectangles). Red rectangle is currently selected method.

What I like about this tool the most however, is that it gives you great high level insight into your projects. In one glance you can literally see granularity of your code, and standard metrics that are ran when you load project give you indications about places in your code, that you possibly may be interested in refactoring (too long methods, methods with to many parameters, unused methods and members, stateless methods and classes and so on). It’s very powerful tool and I’m going to post more when I dive deeper into it.

Oh, and if you want to play with this tool, there is a free version that has very few technical limitations compared to professional version. You can grab it here. Have fun.

Technorati tags: , , , ,