Structure 101 – my new favourite code quality tool

Jetbrains recently sent out an email about a new companion product to Intellij idea – Structure 101. Structure 101 is a tool developed by headway software, which can be used to analyse the architecture and complexity of java applications. This is a very welcome addition to the marketplace for java development tools. (I say new – in fact it seems Structure 101 has been around for a couple of years now, so clearly I’ve not been paying attention!).

Structural problems in code

I am known to be opinionated about this and friends and ex-colleagues will already be bored with me going on about it! The majority of software is not well architected and well structured internally (perhaps in part because the tools to visualise structure at a package level have not been widely available). Some apps are structurally akin to a bowl of spaghetti, with all the negative implications of tight coupling between packages and cyclic dependencies. This is bad news for reuse – if software is full of dependency cycles, classes and packages can’t easily be reused in another context without sucking in everything else too. An acyclic structure is enormously important at the package and class level – not just at the level of the release unit. After all, a release unit today may need to be split into two in the future – to enable better reuse of some of the logic it contains.

Improving structure to remove dependency cycles between packages and classes can be hard – but it is not insurmountably hard, especially if you have the right tools for the job. And it pays major dividends, resulting in far easier reuse and a more intelligible project in the long term. Changes made to projects developed with these principles in mind tend to be more deterministic in their impact, since the ripple-through effect is minimised. And the great thing is that the methods required to achieve this decoupling are well known and accepted as good programming practice in their own right – chief among these, that concrete classes should depend upon abstractions. Introducing an interface is the most common way to decouple a cyclic dependency between two classes.

Avoiding bad structure

This is where tools like Structure 101 come in. It allows you to zoom in to view dependency problems within your application, and makes it far easier to visualize the layering and package structure within your project. Not only that, but it gives a summary of complexity, highlighting classes and areas which need simplification.

This is not a radically new goal. Other tools have attempted the same thing in the past, for example ‘Pasta’ (which became OptimalAdvisor), and ‘SmallWorlds’ (which became SA4J). Both of those were promising products which were swallowed up by big companies and disappeared for a time, stagnated or became prohibitively expensive. However, there is some genuine innovation in Structure 101, over and above the others. I have found it to be effective in zooming to the areas of applications which are the most problematic. It lacks the refactoring support which OptimalAdvisor provides – but then most developers would use their IDE for refactoring in any case, so it is not clear this is a significant disadvantage.

One feature I particularly like is the ability to upload structure diagrams to a shared repository. IDE plugins are then provided which allow developers to validate their changes against a shared model – without having to purchase a license. This is a great idea, which will facilitate much wider use of the tool, and allow teams to collaborate much more easily to maintain a desired architecture. This may help to overcome the natural entropy shared by all multi-developer projects. However things are still not perfect – licenses are node locked, which means a developer may need two licenses to allow him/her to work from home and in the office.

All things considered, Structure 101 is a tool it is certainly well worth checking out – it is my new number one tool for validating the quality of code.


You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

AddThis Social Bookmark Button

Leave a Reply