Visual Studio 2010: Visualizing dependencies

Visual Studio 2010 introduces new and cool feature – architecture diagrams that visualize dependencies between assemblies, namespaces and classes. In this posting I will show you how these diagrams look like and provide some explanations about how to read them.

I tested architecture diagrams (or should I say dependency diagrams?) with one of my small projects. Okay, I tried to visualize dependencies found in source code of KiGG too but it was too big for current implementation of dependency visualizer. But for smaller projects it works pretty well.

You can find these diagrams from Architecture menu of Visual Studio 2010.

Assembly dependencies

As a first thing I generated dependency diagram for assemblies. There is one main dll and it is related to violet block labeled as Generics. Blue block is my assemby and generics block shows all the generics I am using. Externals block is for external assemblies and on the following screenshot it is expanded so you can see other assemblies on what my own assembly one depends.

Visual Studio 2010: Assembly dependencies diagram.
Click on image to view it at original size.

Namespace dependencies

Namespace dependencies diagram illustrates dependecies between namespaces. Also here you can see Generics and Externals boxes. Purpose of them is same as before. On the following screenshot you can see class dependencies in my project. Bookmarks2LiveWriter box is expanded and it contains classes in this namespace. Class ExceptionBox is also expanded and you can see how method dependencies are visualized.

Visual Studio 2010: Namespace dependencies diagram.
Click on image to view it at original size.

Class dependencies

Class dependencies diagram illustrates dependencies between classes. As on previous diagrams you can see also on this diagram the lines with different thickness between classes. Thickness of line gives you some idea about how dependent one class is of another. Thicker line means heavier dependency. Direction on line shows what class is using what other class.

Visual Studio 2010: class dependencies diagram.
Click on image to view it at original size.

Custom dependencies

You can also generate custom dependency diagrams that illustrate things ust like you want. The result is something like you can see on screenshots above. Only new thing is dialog that lets you specify what you can see on diagram.

You can see this dialog on right and if it is too small for you then please click on it to see it at original size.

Right are in this dialog is reserved for example diagram. If you change the state of check boxes you can see on example how generated diagram looks like. After clicking Ok custom architecture diagram will be generated.

Matrix View

It is possible to view dependencies also as matrix. You can see dependencies matrix on following screenshot. You can see that I have disabled some options in legend – it is because otherwise matrix will be very large.

Visual Studio 2010: Matrix view of dependencies.
Click on image to view it at original size.


Dependency diagrams are very useful tools when you analyze dependencies between different components in your system. Less dependencies mean usually less problems because changing one part of system causes less changes to other parts of system. I think these diagrams are good addition to code analysis reports because sometimes one picture can tell more than 1000 words.

Currently dependency diagrams are generated pretty slowly. But I hope it will me much faster when first stable version of Visual Studio 2010 hits the streets. Currently you can save diagrams as XPS files and it also possible to copy diagram or legend to clipboard as image. It is pretty easy to take those diagrams and make them part of your project documents.

Liked this post? Empower your friends by sharing it!

View Comments (5)

Related Post