Click here to Skip to main content
Click here to Skip to main content
Technical Blog

Tagged as

NDepend–Visual NDepend

, 4 Feb 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
Visual NDepend, the stand alone program and the functionality it supports

The last post went over the report that NDepend generates, this post is going to focus on Visual NDepend, the stand alone program and the functionality it supports.

Interactive

The difference between the report and Visual NDepend (from now on, I’ll just call it NDepend) is that you have much greater ability to drill down into the code base allowing you to jump between various graphs/diagrams, you can then right click on the item and jump to a different view with the specific item the focus of the graph/matrix.

NDepend Project

NDepend, in its various flavours, has its own project file which contains all the settings necessary for NDepend to function. There is no dependency to have the project file sit with code base it related to but I would suggest that it is a good idea to keep it with the solution you are analysing and check it into your VCS as well, especially if you start customising the rules, etc.

Unfortunately, because customizations are stored in the individual project files, currently it is not easy to share any customizations across projects but in the comments to this post suggest the makers of NDepend are working on it.

Getting Started

NDependWhen you open up NDepend, you should feel right at home as it has the distinct look and feel of Visual Studio.

When you first open it, you will be presented with a screen that presents you with all the things you are most likely to need – links to videos on the NDepend site, buttons to install the AddIn’s for Visual Studio & Reflector & you will also be able to see if you are running the most up to date version of NDepend.

The left hand area displays recent projects you may have worked on and provides links to create a new project from scratch or analyse existing Visual Studio solution/projects, .NET Assemblies or compare 2 code bases.

image

Once you’ve selected the solution/project to analyse, NDepend will perform the analysis and display the results.

At this point, the information that is being displayed is effectively the same as what is contained in the report. It has the summary which contains the same information as the application metrics on the report, it's got all the CQL rules that were run and an indication if they passed similar to the reports menu listing of the rules.

Analysis Using Graphs

At this point, you are now able to start moving between the different graphs and matrices to explore the code base. The report just had the images showing each of the graphs with no additional information, however in NDepend these are interactive and you can get a lot more information out of them.

For example, in the dependency graph, hovering over any dependency will highlight the dependencies for that item and the Info panel on the right hand side will be populated with metrics about that item. When you right click, you can then jump to the another view, such as dependency matrix, to see the analysis in relation to that particular view.

Analysis by CQL Rule

If you select any of the CQL rules that have been run, then all of the graphs/matrix will indicate the various parts of the code base that match the rule providing a visual way to allow you to focus on the items that are violating the rules.

As well as altering the graph, the CQL Query Edit will display the rule and show the classes, methods, properties, etc. that have violated the code (assuming you have selected a rule that has been violated) and if you double click that item, it will open the solution/project, if not already open, and display the code although this hasn’t always worked for me.

As you select the various rules and navigate the UI, you can see that this way of looking at your code base is much easier as it can allow you to focus on the areas identified rather than simply drilling down into the analysis.

CQL Querying

As impressive as the analysis is, in my opinion, the ability to generate your own CQL queries to be able to create your own rules, all you need to be able to do is think about what you want to query. To make it even easier, the query editor also has auto complete to help you to construct the queries and shows you live results as you create the query.

Any queries that you create are saved in the project file and will be run against the code base the next time that NDepend runs an analysis.

Options

As you would expect, you are also able to configure a lot of the behaviour of NDepend through the GUI, such as whether it runs a full or incremental analysis, if an HTML report is created & displayed, etc.

There are configurable options for the majority of the functionality within NDepend even down to the colour scheme of the GUI itself and if you want to use a ribbon rather than a toolbar interface.

Visual Studio AddIn

As well as the stand alone application, there is the AddIn for Visual Studio which adds an additional menu item to access the functionality that is available in NDepend directly in Visual Studio so you get the graphs/matrix, CQL explorer, CQL Query, etc. without having to leave the IDE.

The one additional thing that the AddIn does that NDepend doesn’t do is to allow you to create a NDepend project for the currently loaded solution and it will add that file to the solution for you.

Summary

What I’ve covered here is really only scratching the surface of what NDepend can do, I haven’t even covered code base comparison or test coverage, both of which are options available to you as well.

It is this functionality that is of real use to individual developers especially allowing you to jump into the specific bits of code that have been identified as needing attention.

The ability to create your own CQL queries to investigate your code base is great but the inability to easily share these queries/rules between projects is an issue, but hopefully it will be resolved by NDepend soon.

What’s Next?

In my final post, I’ll be summarising what I’ve covered and have some general thoughts around NDepend.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Nathan Gloyn
Nock Consulting
United Kingdom United Kingdom
Passionate developer, designer, Certified Scrum Professional, wanna-be architect, agile evangelist, and presenter.
Follow on   Twitter

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.1411023.1 | Last Updated 4 Feb 2012
Article Copyright 2012 by Nathan Gloyn
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid