Review of NDepend 5 Professional

WARNING 34 megabytes of animated GIF screencaps ahead!! WARNING

Disclaimer: More than a year ago I received a MVP Pro license from NDepend team, and they never told me to write a rave review about it, they just asked to help spread the word. So here is me keeping the promise :) Please read my sincere review of the NDepend 5 Professional.

What is NDepend?

NDepend is a static analysis tool for your .NET code, that is, it eats your code, digests it and then it can entertain you with very sophisticated graphs and dependency matrix and, moreover, you can ask it different questions about your code.

The workflow

You can use NDepend as a standalone application or have it running inside Visual Studio. So you start with selecting either existing Visual Studio Solution, or point NDepend to a folder containing assemblies you want to analyse.

ndepend load assemblies dialog full size

Once NDepend is done analysing code, you will be presented with HTML report and the application will display a dashboar.

Dashboard

The dashboard is quick way to examine the overal state of the analysed code. You can follow links and play with results.

Dashboard full size

The dashboard has very important section, which displays information on Code Rules. You can define your own rules which are specific to your oranisation needs, or (modify and) use set of default code rules.

Code Rules

Examine default code rules full size

NDepend can help you with code review process. When someone commits new code, you can see which rules this new code has violated or which violations have been fixed.

Examine default code rules

[Update] NDepend code DIFF feature can help you see what exactly changed between different builds. Just define the projects to compare and scan code changes:
NDepend code DIFF feature full size

Code Rule violations can have different level of severity. If a newbee team member breaks API interface, this kind of violation will stare at you with its yellow warning triangle. Even if the change was done on purpose, you can ensure the change did make it into the build!

critical rule violation full size

Graphs and Matrices

NDepend can help you understand codebase of virtually any size. NDepend has set of graph and matrix views which will help you find dependencies and problems in your code. Using search feature you can find and visualise complex hierarchies of dependent entities. For example you have some base entity and need to review its descendants.

finding classes implementing base class full size

Or you need to BIN deploy an assembly and need to know which assemblies to include into the package:
finding assemblies we depend on full size

NDepend is here to help if you do not have much time to read a lot of code just to be able to know where to insert your two lines bugfix.

Say, you have been assigned with a task which requires you to make some changes to some authentication related code. So you need to understand what code to change and where most of the code is located. You always can just search for Auth code inside Visual Studio, or even use Object Browser to locate relevant types, but it is much easier and informative to do with NDepend.

Just type Auth and have the heatmap of auth-related code. You can quickly see the core assembly, you can see where else are the methods, you can drill down to very obscure places in the code - all of this from one UI.

ndepend finding assembly to investigate full size

And I have not touched matrix analysis yet! Well, I will not dig into matrix view in this post, due to complex nature of this feature, but you can read more about it here and here is very old, but still very helpful Hanselmann article to help you understand the power of the matrix analysis feature.

Metrics

Using NDepend metrics you can easily spot code that needs refactoring. You have access to ready made queries that can filter out problematic code, and those queries can be edited to match your company standarts.

ndepend code refactoring queries full size

And here is how it works:
finding code to refactor full size

Code Quality Trends

NDepend allows you to keep track of your code base quality metrics. Using NDepend Project Properties, you can define baseline project to keep your analysis results, which NDepend will use to build trends reports:
code quality trends full size

Other Uses And Wrap-Up

In this flashy animateful blog post I tried to show off the features I liked the most. I honestly liked the matrix, but I do not have suitable project (which I can publicaly show) that would allow me to explain all the benefits matrix provides.

Another huge feature I have not mentioned in this post, is the ability to use NDepend as a part of your continuous integration process. You can have your own set of rules to break the build and developer, who has broken the build will have no other way around it, other than fix the violating rule. Yes, you can have similar effect with FxCop or tools alike, but with NDepend you get almost an entire IDE to build your perfect set of rules. And it's pure awesome!

Above are the pros. Here is the list of cons:

1) it has kind of a steep learning curve
2) sometimes mouseover popups are blocking you from seeing what you want
3) it takes some time to figure out how to navigate out of analysed code jungles
4) the price is much higher than your average iPhone app :)

I hope you enoyed it. Please let me know if you have any questions or would like some aspects of NDepend explained in future posts.

PS: I have used ServiceStack open source project, to which I recently contributed a set of OAuth authentication providers. Check it out!