Friday 3 February 2012

NDepend–Visual NDepend

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 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 & 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, its got all the CQL rules that were ran 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 graph’s and matrices to explore the code base. The report just had the images showing the 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 a 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 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 a 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.

No comments:

Post a Comment