BT
x Your opinion matters! Please fill in the InfoQ Survey about your reading habits!

IntelliJ IDEA's Dependency Structure Matrix Tool Visualizes Architecture

by Michael Bushe on Feb 12, 2008 |

A major characteristic of good architecture is layering components such that dependencies between modules flow down through the architecture.  Describing and maintaining dependencies between components is a common yet difficult task.  UML package diagrams offer a way to describe such dependencies, but they are often time consuming to create and, even when reverse-engineered, it takes a long time to acheive a grokkable layout.  UML also doesn't scale well - maintaining dependency diagrams in UML for large complex systems rarely provides as much payback as the effort invested.

A newer technology, Dependency Structure Matrices (DSM), has emerged to fill this gap.  DSM presents a matrix where each row is a module and the columns show the same set of modules in the other dimension.  Each cell shows an intersection of two modules and a count of the dependencies between them.  Without any more information, one can quickly intuit the beauty of DSM visualizations through this classic example.

 

DSM of a layered system


DSM of a Layered System



DSM of a strictly layered system.


DSM of a Strictly Layered System


Going beyond the quick glance, each row represents a package in a layered architecture.  The rows are numbered 1-5.  The columns are also numbered 1-5, and represent the same modules, respectively.  In the strictly layered system, the application depends only on the model (37 times), the model depends only on the domain, etc.  In the layered system, higher layers, such as application, can depend on any lower layer, such as util.  Given this visualization, if code is written that breaks the rules, it will be immediately obvious.  Any dependencies showing up in the upper right would break the architecture's intention.

IntelliJ has introduced a new DSM tool in the new "Magnificent 7" release.  Instead of having to think about the intended layering of a codebase and arrange a UML diagram manually, IntelliJ will automatically generate a DSM from an existing project.  Like other DSM tools, it automatically arranges nodes so that the dependencies tend to show up in the lower left.  A DSM is interactive and drillable to the class level:


DSM for the EventBus, drilled to the class level


IntelliJ DSM of the EventBus library


In this example, IntelliJ's DSM tool shows that ReferenceStrength is used 4 times in a layer below it in the architecture.  Having a DSM tool integrated into an IDE is very handy.  IDEA can easily show all 4 references in the codebase, making the problem easy to fix.   In this case, ReferenceStrength can be moved to a higher-level package using IntelliJ's refactoring tools.  

navigation to the broken dependency


IntelliJ DSM Navigates to a Broken Dependency 


IntelliJ's DSM tool has room for improvement.  Unusual for IDEA, it lacks the usability acheived by numbered rows and columns shown earlier.  Other tools, such as Lattix, have more powerful refactoring support.  Lattix can move classes or packages directly from the matrix visualization.  

Lattix Refactoring


Lattix Refactoring 


DSM is a powerful tools that is making its way onto the desktop of more practitioners.  

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Another good tool by Pete Haidinyak

I use Structure101 which does a great job at visualizing dependencies between modules.

Maybe IDEA 8.0 will be better? by Ted Young

The addition of DSM to IDEA is really nice, but I agree that it'd be great to be able to refactor directly from the matrix. Of course, without better documentation, IDEA's DSM isn't going to get much use. Hopefully JetBrains will release new documentation soon.

- Ted Young

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

2 Discuss

Educational Content

General Feedback
Bugs
Advertising
Editorial
InfoQ.com and all content copyright © 2006-2014 C4Media Inc. InfoQ.com hosted at Contegix, the best ISP we've ever worked with.
Privacy policy
BT