Skip to content

August 13, 2013

4

Great New ReSharper Feature – Dependency Graph

by adamstephensen

If you are a ReSharper user (and you should be), check out the new dependency graph. It is awesome for easily getting a high level view of the dependencies between projects and layers in your solution.

clip_image002

Figure: ReSharper 8 introduces a dependency graph to its architecture tools.

 

 

clip_image004

Figure: I structure my solution to reflect the Onion Architecture. http://rules.ssw.com.au/SoftwareDevelopment/RulesToBetterMVC/Pages/The-layers-of-the-onion-architecture.aspx

I have layers for UI, Business Logic Interfaces, Repository Interfaces and the Domain Model. I then inject my dependencies into these layers.
I like to structure the dependencies under a different solution folder so as to emphasise that the dependencies exist outside of the application core.

 

 

clip_image006

Figure: R# now generates a dependency graph of your solution (or a selected part of your solution) and by default groups the projects by Solution folders.

I love this because with a few clicks I can get a very clear idea of the dependencies between the different layers in my solution, and see where references exist to dependency projects.

I unselected three items to remove noise from the diagram: the Solution Items folder (which contains the deployment project and documentation), the Common folder (which contains cross-cutting concerns) and the Dependency Resolver project which configures the IOC container.

 

 

clip_image008

Figure: I generated the ReSharper dependency diagram as preparation for the first Sprint Review meeting and immediately noticed a dependency from my Client (UI) layer to a ‘Dependency’ project.

No No No No No !!!

 

 

clip_image010

Figure: We refactored to inject the dependency into the application core and removed the reference to Data.FileStream from the UI Project.
The dependency graph now looks awesome ! There are no lines from the Clients window to the Dependencies window!

 

 

clip_image012

Figure: As a comparison, this is how the Visual Studio Dependency Graph looks when first created. I would usually then remove the outlined items to remove noise.

 

 

clip_image014

Figure: After removing the extra projects, my Visual Studio Dependency Graph is more readable, but I would love to see the ability to group projects by Solution Folder.

 

 

clip_image016

Figure: The Visual Studio architecture tools are more complete and advanced than the ReSharper ones at present and the Layer Diagram is an invaluable tool that allows you to specify all the layers of your solution, assign projects and classes to particular layers and then have the architecture validated when you build.

 

What I love about the ReSharper dependency graph is how easy it makes it to get a high level overview of my solution.

It also has the ability to track changes to your architecture as your project progresses, and to indicate metrics. I’ll let you know how these features work out for me as the project progresses.

Advertisements
Read more from Tools
4 Comments Post a comment
  1. Greetings! Very helpful advice within this post! It’s the little changes that will make the greatest
    changes. Many thanks for sharing!

    Reply
  2. Jun 6 2014

    There’s definately a great deal to know about this topic. I love all the points you have
    made.

    Reply
  3. Jun 6 2014

    Hello, Neat post. There is a problem along with your site in web explorer, may check this?
    IE still is the marketplace chief and a large portion of other folks
    will leave out your great writing due to this problem.

    Reply
  4. Hello! This is my first comment here so I just wanted to give a quick shout
    out and tell you I really enjoy reading through your posts.
    Can you recommend any other blogs/websites/forums that cover the same topics?
    Thanks for your time!

    Reply

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

Note: HTML is allowed. Your email address will never be published.

Subscribe to comments