When our projects reach a certain size it is very hard to determine the complexity of our code. It gets harder and harder to see the overall picture. It also becomes very easy to introduce unnecessary complexity to parts of our system that we don’t want to. In simple words, it’s easy to get lost. Especially if there are may people working on the project.

On top of many other tools, practices and principles like unit tests, integration tests, acceptance tests, continuous integration, it is static code analysis tools like NDepend that come into play.

The very first time I stumbled upon this fantastic tool was when I was looking for exactly that: a static code analysis tool to show me which one of my modules is connected to(using) another and present it in some sort of visual graph.

But I was soon to find out that NDepend is much much more. I mean there are tons of features there that you can use on a day to day basis in situations where you don’t want to stray off course.

I will examine some of the features that I find very useful in my work, but there’s much more. You can refer to NDepend official website for complete reference.

First of all I like the fact that it is integrated in Visual Studio. You can hook it up(attach) to your project. It will create a .ndproj file in your solution folder and you are ready to start measuring and analyzing.

Second best feature for me is simplicity. It’s as easy as clicking the ‘Analyze’ button. It will create a report for you that is very nicely formatted and transparent.


You also have access to a dashboard in Visual Studio that provides easy access to all analysis.


Code Rules and Code Query

What it does here is that it uses a LINQ-like language called CLinq to do the code analysis with some pre-programmed rules. But it also provides a way for you to create your own.

Code Quality

This one I especially like. It gives you lots of different measurements on code complexity like: Lines of Code, Cyclomatic Complexity, Coupling, Nesting Depth, Rank, NDepend supports them all (and much more).

NDepend also provides some facilities that will help you to detect metric anomalies and to fix your own thresholds. The NDepend UI displays an interactive view of the architecture of your .NET applications. Such a view can be tuned according to numerous software metrics and can be saved in a PNG file in order to let you print posters.


You have all sorts of diagrams to explore your existing architecture. You have a dependency graph, a dependency matrix, Abstractness vs. Instability graph etc. All this helps you see how your code is structured in a nice transparent way. Providing you nice information that you can act upon like design smells, unnecessary dependencies and so on.

Trend Charts

This is one also quite useful feature. You can create trend graphs and measure your progress trough time. Being that number of code rules rules violations, lines of code, unit test coverage, max and average values for various code quality metrics. You can see how you have progressed trough time and how much your code has improved, or degraded.
There are also tons of other very useful features of NDepend like continuous integration reporting, comparing builds and code diff, detecting dependency cycles and so on. Here I just wanted to point just some of them out. You can explore more on their website: http://www.ndepend.com/

Hope someone else finds it as useful as I did.
Until next time.

Happy coding.



Posted by TheBoyan

I have been programming since I was 11 years old (Yes, I'm one of those, for real). First programming language I learned was BASIC, on a Commodore64. Then around high-school it was C and Assembly. Just before and during university days it was C++. I started doing some professional work during this period, part of the reason why I dropped out of uni in my final year. I have never stopped since then. Going through a plethora of technologies ranging from C and Assembly languages, Delphi to C++, C#, Java and so on and so forth... trough 20 (and more, who counts, does it even matter) years of software development. I have not lost even a single bit of my ambition and love for the craft from those first young days, nor the energy...I absolutely love what I do. I like to get my hands into all aspects of software development. Now-a-days I use mainly Microsoft related technologies .NET C#, with a lot of database design/management usage of SQL server, but not in any way limited to that.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s