Visual NDepend Blows My Socks Off!

Posted Thursday, February 26, 2009 5:10 PM by Nathan Zaugg


I’m not easily impressed by even the best of software.  There is usually some little thing that ruins my user experience.  I tell you this so you know that what I say next is something special.  Visual NDepend is AWESOME!  Everything meet or far exceeded my expectations!  If you are not yet running this software, you should be!  This is not one of those ‘nice to have’ pieces of software like you might thing.  This is a must have!  If Microsoft was smart they would do everything they could to package this in with Visual Studio 2010. 

What does it do? It’s hard to answer that question in a paragraph or two.  The basic answer is that it gives you a set of different representations of your software in such a way that you can understand the architecture and complexity.  This can be a huge help before undertaking large refactor efforts.  It also gives you an idea or the quality of the code based off of some metrics.  This quality score can be a really good indicator of wither your code is going to be maintainable and if it’s not it can help you get it there.  Before I go through the quick walkthrough of the software it’s self I’ll just say this – If you’re not paying attention to code metrics and the maintainability of the code from the earliest stages of development your likely not going to develop code that is easy to maintain.  And as you probably know, software maintenance is usually more than 3/4ths the cost of the software lifecycle.  Therefore, if you can get a build process established early and use a tool like NDepend to keep a close watch on some important metrics I can guarantee you will be creating much higher quality software than you would have otherwise.

Installation Experience

This is the best kind of install – you simply unzip the files.  I bet you didn’t think I would do a whole section on install when there is nothing to the install.  I suppose if it were any other product there would be a lot under this section. 

Analyze a Project

The user interface is very intuitive.  I installed integration with Visual Studio 2008 and .NET Reflector with minimal effort and started to analyze my assembly. 


Main Screen

It took a while to analyze but this particular assembly is quite large!  It also pulls in any referenced assemblies so the graph can be complete.  It allows you to specify multiple assemblies just in case you have sets of assemblies in the same project that have no direct relationship.  In this case I had a WCF service that would need to be added separately as it’s technically not a direct dependency.  Once the analysis is complete it’s INFORMATION OVERLOAD!



There are six or seven main results to view.  The most obvious is the bubble chart at the top.  This gives you a visual representation of different aspects of the code.  For example it’s currently set to Method level and the metric shown is number of lines of code.  the larger the bubble, the larger the method is in relation to the others.  I can select from Method, Field, Type, Namespace or Assembly.  In addition there are 11 different metrics that you can plot in the bubble chart. 

Bubble Chart

The next thing you notice is the dependency graph.  Unfortunately this project doesn’t have a dependency graph like in my other blog post.  Visual Studio makes it really tough to make circular dependencies but it is possible to create them if not all of your projects are loaded into the same solution.  And as I said in the other post, circular dependencies are very bad!  It’s also good to know what references what.  You might be surprised to see what kind of references get worked in over time.  On a recent project the data layer code kept working it’s way up to the UI even though it didn’t belong there. 

Dependency Graph

The next section is the code metric-centric part. This is my most favorite portion of the results generated and can be a real good indicator of how maintainable a codebase is.  Of course it’s impossible to avoid all complexities in software so you probably can’t have a perfect score with every project but you can use this information to figure out what kinds of habits you have that contribute to un-maintainable code. As you can see from the image below when you select a metric it is highlighted in the bubble chart.  In fact, all of these reports are “active” so anything that is relevant to another will be indicated.  By the way, this application has amazing performance.  I’m pretty sure it’s using WPF under the hood.

Code Metrics 

Methods Too Big

Another really cool feature is the Dependency Matrix.  This takes some practice to use but it helps identify which pieces of which assemblies access pieces of other assemblies.  Again, great for refactoring efforts and a good indication of how an application is put together.  You may have to stair at the image below for a while to figure out what it’s trying to tell you but after a while it makes perfect sense.

Dependency Matrix

Last, but certainly not least is the comprehensive report compiled into HTML.  This is the kind of thing that I’d love to see emailed to me each day, so I hope it’s easy to put this into a build process.  The report is awesome!  My favorite part of the software and I really like this software.  Below is the screen shot of the table of contents that is generated at the top. 

Analysis Report

The only feature I didn’t get a chance to try is code coverage results.  I would have loved to see that in action!  Too bad I don’t have a project with very good code coverage results and I’d be embarrassed to find out anything in detail about my code coverage.  Of course code coverage isn’t everything but it is a useful tool when taken into context and can be made more useful with nDepend.

Overall, I would give this software very high marks!  I can’t wait to make this part of my build process!  It is worth the time and money!



# re: Visual NDepend Blows My Socks Off!

Sunday, March 29, 2009 11:31 PM by RaiulBaztepo


Very Interesting post! Thank you for such interesting resource!

PS: Sorry for my bad english, I'v just started to learn this language ;)

See you!

Your, Raiul Baztepo