NDepend Initial Review

The other week I was amazingly fortunate to receive an email from Patrick Smacchia – the lead developer working on NDepend. In order that I may review it here on my blog he provided a full featured pro version. In short … amazing. Both the generosity and the software.

I duly pointed FireFox at the NDepend site and downloaded the software. Within a handful of minutes I was looking at an NDepend report of my current Project SampleSort. I don’t think I’ve ever ‘looked’ at code in quite the same way before. One of the really great NDpend features is a graphical representation of your code structure, at first glance it could easily be some graphical representation of complex chemicals in a chemistry textbook, that is until you start mousing around it and having a peer into what its actually representing.

This graphical representation can be used as a navigator around each method, within each class, in each namespace within your .NET assembly files. When clicking on one of these ‘bubbles’ the class browser will fly to the relevant item, right clicking then displays a context menu with a plethora of options for you to choose from including finding out dependencies and how it generally integrates with other parts of the code base. You can also launch the dependencies viewer from this menu. One really neat feature of this view is that using the metrics combo box allows you to select the metric this graphical view represents and the application then re-draws the bubbles based on the results of the analysis. Really cool indeed.

You can also double click in the visual representation window to view the actual code, a really neat feature. One thing I would love to see in this view is syntax highlighting. Presently the code opens in the standard Windows notepad text viewer but I have Notepad++ installed which already has syntax highlighting built in, maybe the NDepend development team could allow the user to configure this as the default code viewer in order to leverage these features ‘for free’. When you have selected an element in the tree view class browser another pane below the class browser shows more detailed information about the element. This information is very detailed, it includes:

Return Type

IL Instruction Count

LOC (line of code)

Lines of Comment

Percentage Comment

Cyclomatic Complexity

IL Nested Depth

Parameters

Variable

Method Level

Efferent coupling

Afferent coupling

Method Rank

This list of metrics obviously varies depending on what is selected. Also for really powerful use of these metrics each analysis of a project is recorded and can be compared meaning you can get a real feel for how the complete picture of the code base is changing through the development process over multiple iterations of the same application. Not only that but in a large development project utilising many developers NDepend will integrate into the CI process and provide a means of reporting issues as part of the build process.

Basically this is a fantastic tool that has already provided me with information I need in order to improve the robustness of my code, if you were using this tool to interrogate a code base your not familiar with it would be completely invaluable.

CQL

Code Query Language = Genius in my opinion. It borrows from standard SQL syntax in order to provide a really innovative way of exploring your code. It comes with a bundle of useful pre-built statements which are a great starting block for building your own queries. There is also a facility that allows you to build custom queries using the query builder or to embed custom queries (and constraints) into the actual source code itself. The real beauty is that once you have performed an analysis of your code base building a query presents you with the results as your building the query. Brilliant! An example of the syntax is:

[source:c-sharp]
SELECT TOP 2 TYPES FROM NAMESPACES WHERE CouldBeInternal
[/source]

Ok, that will do for starters, more to follow on this tool as I use it and explore it some more … go and grab a a trial version, you’ll be looking at your code with fresh eyes.