Thursday, March 20, 2008

NDepend - Great Static Analyzer

Few week ago, I've been asked by Patrick Smacchia, a C# MVP to try this tool. I really want to thanks Patrick to give me the chance to evaluate a professional edition.

I installed it and start working with. After using this tool, it's my most favorite tool to reviewing my code!

NDepend is an excellent tool that is designed to provide a very deep analysis of your compiled code to help you understand and control your development effort by managing both the quality and the complexity of your code. NDepend works in a very similar way as the Microsoft FxCop tool, by analyzing your compiled code and calculating different metrics and statistics on that code.

NDepend analyzes your code against more than 60 different metrics and can be customized to a particular application. These metrics measure things like:

  • Lines of Code, Comments and the percentage of comments
  • Number of IL instructions
  • Number of Assemblies, Namespaces, Types, Methods, Fields
  • Coupling (both Afferent and Efferent), Cohesion and Cyclomatic Complexity
  • Instability
  • Abstractness
  • Depth of Inheritance

NDepend's start page:

Start Page

NDepend's analyzing result and projects loaded:

Analyzing Result

A great feature is the NDepend's CQL (Code Query Language). It is the one of its main features that I love.  It's a query language for code so one can issue statements like:

SELECT TOP 100 METHODS ORDER BY NbLinesOfCode DESC

Its great to query your code this way, besides we're all familiar with T-SQL... :)

Visual NDepend also has this metrics view which graphically represents any criteria from number of lines of code such as represented below, to number of methods, parameters, coupling, etc.  The bigger the square below means more number of lines of code.

Another feature for the professional edition (not available in the free edition) is the build comparisons.  It basically analyzes two build versions, analyze what's been deprecated, broken, etc.  It's useful to easily know if an upgrade to a component you're using will break your app.  It also provides easy access on the details of what has been changed.

The binaries also include extensions for MSBuild, NAnt and CruiseControl.NET so you can readily include NDepend tasks in your build scripts for your continuous integration setup.

NDepend is great for architects or even team leads who wants to have a quick overview of their project rather than diving into the code and scratch their heads.

Addins of NDepends available to VS2008, VS2005 and Reflector.

NDepends web site: http://www.ndepend.com/

No comments: