InfoQ

News

IntelliJ IDEA's Dependency Structure Matrix Tool Visualizes Architecture

Posted by Michael Bushe on Feb 12, 2008 04:45 PM

Community
Architecture
Topics
Artifacts & Tools,
Code Analysis
Tags
IntelliJ IDEA,
Visualization

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.  

2 comments

Reply

Another good tool by Pete Haidinyak Posted Feb 13, 2008 10:31 AM
Maybe IDEA 8.0 will be better? by Ted Young Posted Feb 23, 2008 12:53 PM
  1. Back to top

    Another good tool

    Feb 13, 2008 10:31 AM by Pete Haidinyak

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

  2. Back to top

    Maybe IDEA 8.0 will be better?

    Feb 23, 2008 12:53 PM 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

Exclusive Content

VMware Infrastructure 3 Book Excerpt and Author Interview

VMware Infrastructure 3: Advanced Technical Design Guide and Advanced Operations Guide provides a wealth of practical insights into setting up virtualization in todays corporate environments.

Architectures of extraordinarily large, self-sustaining systems

Can a system that is so large it cannot be comprehended be "designed" in a conventional sense? The foundations of computing are about to change. In this talk, Richard P. Gabriel explores why and how.

Using Ruby Fibers for Async I/O: NeverBlock and Revactor

Ruby 1.9's Fibers and non-blocking I/O are getting more attention - we talked to Mohammad A. Ali of the NeverBlock project and Tony Arcieri of the Revactor project.

Agile and Beyond - The Power of Aspirational Teams

Tim Mackinnon talks about the aspirations behind the Agile principles and practices, the desire to become efficient, to write quality code which does not end up being thrown away.

Concurrency: Past and Present

Brian Goetz discusses the difficulties of creating multithreaded programs correctly, incorrect synchronization, race conditions, deadlock, STM, concurrency, alternatives to threads, Erlang, Scala.

ActionScript 3 for Java Programmers

Often the hardest part of changing technologies is language syntax differences. This new article provides Java developers with a transition guide to Actionscript which forms the foundation of Flex.

Neal Ford On Programming Languages and Platforms

Neal Ford talks about having multiple languages running on one of the two major platforms: Java and .NET. He also presents the advantages offered by Ruby compared to static languages like Java or C#.

Future Directions for Agile

David Anderson talks about the history of Agile, the current status of it and his vision for the future. The role of Agile consists in finding ways to implement its principles.