IntelliJ IDEA's Dependency Structure Matrix Tool Visualizes Architecture
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.
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:
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.
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.
DSM is a powerful tools that is making its way onto the desktop of more practitioners.
Another good tool
Maybe IDEA 8.0 will be better?
- Ted Young
Ben Melbourne Jul 04, 2015
Randy Shoup Jul 03, 2015