Development Tools – NDepend

I have been playing with NDepend for the past week or so, and have found it to be a useful addition to an Architect’s/Developer’s artillery for larger more complex projects.

NDepend is a static code analysis tool written by Patrick Smacchia (C# MVP) that simplifies managing a large/complex .NET code base.

Whether you are responsible for QA, code reviews, architecture, or day to day development on large complex projects, you will most likely find something useful in NDepend.

Selection by Metrics (top 10 lines of code count) and highlighting of those methods in the Metrics View
Metrics View: Hightlighting the top 10 methods based on number of lines of code.

NDepend provides a visually appealing view of your project that allows you to easily get an overall picture of how your code hangs together, where it is complex, uncommented, fat, or not covered by a test case and more – while allowing you to easily drill down to the specific code in question.

The key feature of NDepend is the “Code Query Language (CQL)” that provides a fast, flexible and easy way to answer questions about your code. For example you can quickly discover all dependencies for an assembly, class, or method / field. Allowing you to easily see where methods are no longer used, or what impact a change you might be planning will have upon other assemblies in a large project. The CQL syntax closely resembles SQL and provides some seriously powerful querying capabilities to your code review process.

CQL to select all methods within the NAnt.NUnit namespace that modify object state that are not thread safe.
CQL to select all methods within the NAnt.Core namespace that modify object state and are not thread safe.

NDepend provides a number of canned CQL queries for reporting on code metrics (82 in total). These can also easily be amended to include, for example, checks against internal naming conventions for private member fields. The results are then highlighted visually in the “metrics” view allowing you to quickly see which assemblies / classes require attention.

A console application is available along with instructions on how to integrate NDepend into your build process, bringing automatic design and quality regression testing to your projects.

NDepend has a number of other features you may enjoy along with some spiffy demonstration movies, so I recommend taking a look at the NDepend website yourself http://www.ndepend.com.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.