here are tons of tools developers can use to inspect code they write at the code level, and some even provide metrics about how complex aspects of the code are, but few work at a higher level of abstraction. Headway Software wants to change that and aims to provide a design-level view of the structure of a code base, point out where the fat and interdependencies are, and show you exactly how these impact your code in much more of a graphical way than most developers are used to with a program called Structure101.
Currently, Structure101 supports Java code but Headway officials say they will add support for C/C++, .NET, and Ada in future releases, though no specific timeline has been announced. Structure101 is written in Java and is available with runtimes for Windows, Linux, and Mac OSX. It comes in three flavors:
- Standalone Client: This application can be used to interactively analyze Java byte code. Data can be published to a Structure101 repository to be shared. The cost is $499 per developer license.
- Publisher: This version extracts data created by the standalone application and can be integrated into a build environment. The cost is $999 per server license.
- Publisher Web Application: This version provides web access to the Structure101 repository as well as cross-project trend comparisons. This application is available for free.
The two main areas that Headway says Structure101 is targeted to assist with are to help control structural complexity and overall component architecture. It does this by allowing you to select your compiled code, to analyze the relationships and interdependencies of your code, to view this information directly in an interactive user interface?and to publish it for the whole team to use.
What Can It Do?
Structure101 helps developers and architects by providing a graphical view of the structure of your code. Primary features supported are:
- Dependency Management: Provides various diagrams showing how all the dependencies in the code are mapped. See figures 1 and 2.
- Dependency Analysis: Provides an interactive way to determine everything that depends on a package, class, or method, and everything that it depends on. There are multiple ways to view this information.
- Structure Analysis: Provides the ability to view the structure of your code from the whole code base including third-party libraries, down to a specific method. In addition, Structure101 can point out specifically nasty groupings of code that need to be addressed. A set of metrics are provided that specifically analyze and point out the areas of code that are in most dire need of attention from a design perspective.
- Impact Analysis: Did you ever want to see what the impact would be to your code to swap out one implementation of a third-party library for another one? Structure101 can show you down to the method what the exact impact will be.
Installing Structure101 is fairly straight forward. I tried it on Windows 2000 and Windows XP using the same download installer that I downloaded from http://www.headwaysoftware.com/downloads/ . The download page has downloadable packages for Windows, Linux, and OSX; although Headway states that there have been some issues with the OSX version which are being addresses in the next release.
Double-clicking on the download file (structure101_java_69_windows_with_jre.exe) launched the installer, which asked me to:
- Accept the end user license agreement (EULA).
- Provide a directory for Structure101 to install itself in.
- Designate a folder for the installer to put shortcuts in.
- Associate a file with Structure101 for *.java.hsp files. These contain the configuration information for Structure 101 projects.
Accepting all the defaults installed Structure101 in C:Program FilesStructure101java. In order to run the program you must request an evaluation key from the download page above. This will result in two files being emailed to the address you register: client.lic and publisher.lic. Copy both of these files to the Structure101 install directory to run the program.
Crank It Up
Starting the program from either the program group or the C:Program FilesStructure101java s101java.exe program opens what looks like a familiar windows application with the standard menus and toolbars.
The first step is to create a new project using either the menu or the toolbar icon. I created separate projects to analyze the JAR files for JUnit 3.8.1, JUnit 4.1, and Spring 2.0, as well as some client code. You can set the level of detail you want to include in the project, which impacts the amount of time it takes to parse and analyze the byte code. Each of these projects was created in 15 seconds or less, and the analysis was immediately available in the application.
One of the metrics Structure101 provides is called XS, which is a measure of how much “excess” is in the structure of your code; the lower the number the better. The XS measurements for the open source projects I analyzed were:
- JUnit 3.8.1: 485 (4.4%)
- JUnit 4.1: 845 (10.9%)
- Spring 2.0: 5,200 (2.5%) (see Figure 3)
From the XS View, you can adjust the thresholds and rerun the analysis. You can also select each slice of the pie chart to filter by that metric. To get more detail simply double click on one of the classes in the Items View and you will be transported to the are of the dependency graph where that class is to do further analysis.
|Figure 3. Here the XS metrics for Spring 2.0 are shown. The five metrics in the lower left corner are set to their default thresholds, and can be customized. Using the defaults, only two metrics exceeded the thresholds: Fat (method) and Fat (class), as shown in the pie chart. The class-by-class breakdown of the violation is shown in the 31 classes listed in the lower right corner.|
These numbers indicate an overall measurement of how well these libraries are structured. I was impressed to see that as large as the Spring 2.0 code base is, it had a very low XS rating. Likewise I was disappointed to see that the XS rating for JUnit has more than double from version 3.8.1 to version 4.1. Of course this is exactly the kind of thing Structure101 is supposed to do; point out complexity and poor structure in your code.
There are several areas to explore for each code base in Structure101, but XS is a good high-level place to start comparing versions of code you write and maintain. This also gives you another way of comparing third-party libraries; Structure101 can give you some quick insight into how well they are designed, which may translate into how much support impact they will have on your applications.
It can be easy to get lost in any good size code base. One way that Structure101 has to help you keep track of where you are is a tagging feature. As you identify methods, classes, and packages that you want to hone it on you can filter whatever view you are looking at by selecting the package, class, or method of interest. Once you leave that view or select another item the filter changes to the new selection. If you want to leave yourself some breadcrumbs of where you’ve been as you trek through your code you can tag items of interest. Structure101 provides a set of tag/untag features available from the menu, toolbar, and context menus from almost any view. Want to see the inverse of what you’ve selected? Just toggle the tagged items to be untagged and the untagged items to be tagged with the inversion option. You can invert tags separately on selected items, as well as dependencies. You can also hide all the tagged items so that you can see what’s left in the model, which can be useful if you are doing a significant refactoring.
Another Structure101 feature is the ability to transform the visual model of the code structure. One example covered in the documentation is when your unit tests are located in the same package as the classes they test, and you want to separate them out to a parallel package structure. You can transform the visual representation of the code inside Structure101 to represent whatever your new, preferred structure might be. The tip in the online help says, “Don’t be afraid to experiment with Transformations?they are transient and you cannot break anything.”
What I Liked
The Windows installer absolutely meets the desired and sometimes mythical 10-minute installation. It was easy and straightforward, with instructions of what to do if the license key has not been installed the first time the program is run.
I liked the visual aspects of the program, how it visually depicted the relationships between various modules, packages, classes, and methods of a code base. Features such as the birds-eye view and the auto-partitioning were reminiscent of computer drafting programs, and their application here is extremely apropos. The ability you have to click through and navigate up and down the structure of the code base is both eye opening and addictive (see figures 4 and 5).
I found the online Flash tutorials great to not only get familiar with the Structure101 concepts, but also to see some of the intent for how its designers envision it being used. The only complaint here was that the demos are of a previous version, and so not all of the newer features are demonstrated. The vendor states these should be updated shortly to incorporate the latest version.
The help system that is built into Structure101 was brief and to the point. It’s great for beginners and for describing seldom-used features; however I found it sketchy on the more advanced features like running from the command line or publishing results to the repository. I don’t think it would be that much effort to upgrade the documentation of advanced features, and this product would greatly benefit from that additional detail.
What I Didn’t Like
I didn’t like that there was no option to download the program without a Java runtime. It seems to me that most Java developers and architects I know?at least the ones likely to use a product like Structure 101?are going to have Java already installed, usually several versions. I don’t mind having the one-stop install, but I prefer vendors to give me the option not to download yet another JRE that may get entangled in my PATH, CLASSPATH, or Registry (on Windows). This may seem like a small thing, but with all the tools and configurations that developers have to manage nowadays, I think vendors will need to continue to search for a balance in how their target audience can most easily assimilate their products into a constantly changing environment. It’s not like an automated installer has ever done that kind of thing to me or anything?
Structure101 reads JAR files and .class files, in other words Java byte code. It doesn’t handle WAR or EAR files. While there are work arounds such as pointing Structure101 at an exploded WAR or EAR, I’d prefer the ability to analyze them directly. While it’s true that WARs/EARs typically include JARs, which can be processed by Structure101, my experience has shown it to be much more common for WARs/EARs to be comprised of .class files that are not contained in JARs before being added to the final WAR/EAR they are deployed in. For this product to be adopted as a standard in enterprise developers’/architects’ toolboxes, direct support for WARs/EARs is not a nice to have, it’s a requirement.
Filling a Need
There’s been a need for a tool like Structure101 for a very long time. The tool had no problems reading any JARs or directories containing .class files from any of the various open source or personal code bases I pointed it at.
Overall I would recommend that tech leads and architects evaluate this product to determine if it could assist you in keeping up with all the various aspects of your ever growing code base. I think that development teams of almost every size would benefit from at least one copy of Structure101. Larger teams could utilize the repository and publisher license to maximize their investment. The value of Structure101 is more about complexity of your code, than the size of your team.
The performance was acceptable, and I experienced no crashes. At $499 USD per developer license or $999 USD for the publisher license, it’s in the affordable range for most software teams. I doubt that every developer would need a copy, but the team would benefit from having a tech lead or architect who could use Structure101 to analyze the code base, and work with the rest of the development team to improve the structure.
I give Structure101 a thumbs-up and look forward to their next release and extended Java and .NET support.