NDepend

One thing in common with developers and infrastructure professionals is that they often turn to monitoring and analysis tools in times of strife rather than incorporate them into their daily routine. If the monitoring and analysis tools are bought out only when there's a problem, then you're often confronted by the fact that no one really knows them well enough to interpret what they're telling you.

That's why I'm spending some time getting to know NDepend now, before I really need it.

NDepend is a tool designed to perform static analysis on a codebase and provide you with a large set of interesting code metrics. It's a tool which offers an incredible amount of value and insight, but it's also one which is going to put a lot of people off by the sheer amount of data it has to offer. One of the keys with metrics and statistics is knowing how to interpret them – NDepend does an incredible job of presenting you with all the data you could possibly need to know about your projects, however the job of understanding how that data actually relates to your day to day development and maintenance is mostly up to you.

The best way to get started with NDepend is to download a copy, open up a project that you know well, and start looking about the UI. There are some great screencasts available to help you get started, and watching some of them is probably a good idea. Another great resource is this podcast from Scott Hanselman – although it's a couple of years old, it's a great way to get an overview of how you could use this product in real world situations, as well as explaining some of the important UI features and common terminology.

Once the analysis has been run against your code, you are presented with a number of different UI elements allowing you to explore the results, as well as an XML report which opens in a browser offering you a static summary. The visual elements offer you different ways to explore your code however you also have the option of running custom queries written in CQL, which is NDepend's own query language. Visual elements include a class browser (used to.. well, browse classes!), a Dependency Graph (which is a very useful visual overview of your project and it's dependencies), a dependency matrix, and a Metrics treeview (which has a similar UI to hard drive size reporting tools such as SequoiaView). Each of these visual elements has a wealth of options allowing you to change how the metrics are presented to you depending on your requirements.

The CQL queries list comes with some pretty useful precreated queries covering areas such as code quality, design, performance, usage of .NET framework, naming conventions to name but a few, and of course you can write your own. When you click on a query or a group of queries, the resulting/offending areas of your code are highlighted on the Metrics treemap (if it's visible), as well as being displayed in the CQL Query results list. Clicking on a specific item from the results list will also highlight where that single item lives in the Metrics treemap.

Queries can range from simple things such as "Show me methods taking more than 10 parameters" or "Show me the 10 methods with the most lines of code" through to much more complex ones. It's worth taking some time to browse through the ones which ship with the product, as they're great examples of the power of the CQL language, as well as being queries that you're likely to want to run against your projects.

There's simply too much in the UI for me to even pretend to attempt to run through it all. You really need to download it and use it to get an idea of just how much this tool offers you.

I think different teams and developers will find different ways to use NDepend.  You could choose to use it only for a milestone reviews or releases, for troubleshooting, prior to any significant refactoring, daily as part of a build process (as the Professional version of NDepend allows you to run CQL queries as part of your CI process), or all of the above. For me, I'm looking to use it as a semi-regular sanity check for what I'm doing, but also to analyze potential codebases which I may "inherit" so I know what I'm dealing with right off the bat. I found that just taking 5 minutes to look at the dependency graph was a great way to get an overview of a project, where the areas of complexity are, as well as what third party assemblies and elements of the .NET framework are being used. It's the sort of graph which is going to make code smell stand out pretty quickly.

There are a couple of things I noticed, but haven't had time to use in depth yet. The most intriguing one of those is the option to compare 2 versions of a code base. It strikes me as being something which would be incredibly handy - I've done it before for a small section of a codebase using Winmerge (an open source merge tool), which did the job, but I can imagine that if you were dealing with a larger codebase that you'd want to be using NDepend instead.

NDepend is a tool which is a valuable addition to any developer's toolkit. You're going to want to spend a bit of time getting to know it, but it'll be time well spent.

Link: NDepend
Link: Hanselminutes episode #66 - Static code analysis with NDepend
Link: Patrick Smacchia's (NDepend's author) blog
Link: JD of Mindscape's blog on NDepend

 Print | Posted on Sunday, January 11, 2009 11:31 AM |



Feedback

Gravatar

# re: NDepend

Nice I was about to trillian you and ask what you've been up to. No need, sounds like it would be ideal for analysing the crazyness of RS - if I was still working on it!

1/13/2009 10:43 AM | Andrew Baird

Gravatar

# re: NDepend

I would like to propose not to hold back until you earn enough money to buy different goods! You can get the credit loans or just student loan and feel yourself free

6/16/2010 11:01 AM | OrrRandi


Post Comment

Title  
Name  
Email
Website / Url
 

Your comment

   
Ensure the word in this box says 'orange':
 
Please add 2 and 4 and type the answer here:





Due to excessive comment spam, all comments are now being moderated. If you're a comment spammer then you're wasting your time here. Your comments will not be published - ever.


About me

My name is Ross Hawkins and I'm a developer, consultant, business owner and writer based in Auckland, New Zealand (pictured below!). My current work revolves around ASP.NET, C#, jQuery, Ajax, SQL Server, and a mix of other Microsoft development technologies.

I also have about 15 years of experience with IBM Lotus Notes/Domino and associated technologies. While Notes/Domino is no longer my primary focus I still like to dabble and keep my skills up to date.

I own and run 2 businesses - Hawkins Consulting Services, and Ignition Development.

Bethells Beach, located in sunny West Auckland, New Zealand




Subscribe

Subscribe to this feed


Search




Popular Content

Troubleshooting WebResource.axd

The .NET 2.0 framework changed the way clientside JavaScript is delivered to the browser. Previously, ASP.NET 1.1 used the aspnet_client directory whereas now 2.0 uses WebResource.axd.

Published on October 8, 2006

Microsoft AJAX Extensions: Sys.Debug is null or not an object

One of the breaking changes which was made with the 1.0 release of the Microsoft Ajax Extensions was the renaming of the 'Debug' class to 'Sys.Debug' for reasons of compatiability with other frameworks. Breaking changes like this can often be a source of frustration..

Published on May 22, 2007

Simple ASP.NET Character Counter

A textbox character counter is a pretty simple piece of functionality, and there's a lot of different ways to apply one to your application. The following method is nice and simple, and can be done using only clientside JavaScript if required, or combined with server side code in order to create a more dynamic effect

Published on December 4, 2006

Simple ASP.NET Character Counter - with Master Page Support

A quick update to my previous character counter article adding some changes for those using it with Master Pages.

Published on February 7th, 2009

Adding Tooltips to Gridview Headers

As the title says, this is a very simple but dynamic way of achieving tooltip text on a header column. It's not overly flash, but it's lightweight and quick to implement.

Published on April 15, 2007

SQL Server Web Report Viewer Issues on Windows 2008 Server/IIS7

A fix for another AXD related issue, this time with the SQL Server Web Report Viewer Control which was being served up via IIS7 on a Windows 2008 server.

Published on June 2, 2007
Updated on April 10, 2008




Archives

January, 2012 (3)
December, 2011 (3)
November, 2011 (8)
October, 2011 (9)
September, 2011 (8)
August, 2011 (5)
July, 2011 (4)
June, 2011 (7)
May, 2011 (5)
April, 2011 (3)
March, 2011 (8)
February, 2011 (4)
January, 2011 (3)
December, 2010 (8)
November, 2010 (5)
October, 2010 (6)
September, 2010 (7)
August, 2010 (11)
July, 2010 (12)
June, 2010 (8)
May, 2010 (8)
April, 2010 (4)
March, 2010 (8)
February, 2010 (6)
January, 2010 (12)
December, 2009 (13)
November, 2009 (11)
October, 2009 (12)
September, 2009 (12)
August, 2009 (2)
July, 2009 (7)
June, 2009 (12)
May, 2009 (9)
April, 2009 (9)
March, 2009 (9)
February, 2009 (8)
January, 2009 (7)
December, 2008 (6)
November, 2008 (7)
October, 2008 (9)
September, 2008 (12)
August, 2008 (9)
July, 2008 (6)
June, 2008 (24)
May, 2008 (13)
April, 2008 (16)
March, 2008 (8)
February, 2008 (10)
January, 2008 (1)
December, 2007 (14)
November, 2007 (11)
October, 2007 (11)
September, 2007 (13)
August, 2007 (11)
July, 2007 (5)
June, 2007 (15)
May, 2007 (11)
April, 2007 (9)
March, 2007 (9)
February, 2007 (10)
January, 2007 (8)
December, 2006 (18)
November, 2006 (11)
October, 2006 (14)
September, 2006 (9)
August, 2006 (10)
July, 2006 (4)
June, 2006 (4)
May, 2006 (6)
April, 2006 (3)
February, 2006 (6)
January, 2006 (10)
September, 2005 (2)
August, 2005 (4)

Post Categories

ASP.NET
AJAX
Amusing
NZ
NZ Trains
Notes/Domino
Visual Studio
Web Development
Miscellaneous
Me
Rugby
C#
SQL