Creating & running software analysis in Rational Software Architect (Software Analyzer)

Off
Strongback Consulting

Rational Software Architect has a much underutilized feature called Software Analyzer built into the product. It is separately available as its own product. It allows the developer/architect to scan and identify build patterns and anti-patterns in a workspace, working set, or specific project in the developer workspace.
These are very helpful to identify potential performance issues. I ran one against a project I’m working on a found some issues that although are not actual programming errors (meaning, the project will compile and deploy just fine), there are some development anti-patterns I either ignored or unintentionally created.

To run a discovery, first click on your project while in then Navigator View, or Enterprise Projects view and select “Software Analyzer”, then “Software Analyzer Configurations”. Be sure and name your analyzer profile first.

Then, select a scope. The scope means which projects or working sets you wish to scan. I don’t recommend you scan your entire workspace, unless you only have a couple of projects. You certainly won’t be able to address all the issues at once if you scan say all 10 projects in your workspace. A single project is ideal.

Next, create select a rule set. There are several pre-defined analyzer rule sets available. There is a security rule set available, but please take these with a grain of salt. Don’t expect them to provide all the security recommendations needed (AppScan source edition from Ounce labs is a good product for that).

In this case I ran the full monty of tests, sans the UML models (as I don’t have any UML models in this particular project). Note the various architectural patterns it has discovered. For this project I make use of Spring, Hibernate, Apache Tiles, and Spring MVC (a framework I am a HUGE fan of). Knowing how these patterns interact with one another give you a better architectural understanding of your applications. If your app is large enough that you have multiple developers, you may not easily be able to tell what patterns (or anti-patterns) are being used by just looking at the code. Yes, you the architect could figure it out. Think of this as a productivity feature that saves you countless hours of hunting and pecking. Knowing how patterns work with other patterns can help you develop more manageable, flexible, and modular architectures. Singletons, Factory, MVC are patterns you should know well, but what about ‘Local Butterfly’ or ‘Inheritance Tree’? Applied Java Patterns
is a great reference book for Java patterns and understanding some of the more esoteric ones.

After running the analysis the results view will popup. There are 3 panes – one for the result set, a tab for the architectural discovery, and one for the code review. You should find several helpful rules for the code review (depending upon which scan you ran). Clicking on the links will give you the option to navigate to the line of code where the trouble or anti-pattern lies. In this case, I was lazy and was doing String concatenation. This can be a performance issue in Java. According to Joshua Bloch

Using the string concatenation operator repeatedly to concatenate n strings requires time quadratic in n.

p. 155 Effective Java (2nd Edition) – Joshua Bloch

In the code, click the icon for the analyzer recommendation and select “Quick Fix”. For my issue, it will refactor the code by extracting a constant, and inserting the constant where the current string is. The string becomes private static final String MSG_SUBJECT = "New Strongback Consulting Contact!"; //$NON-NLS-1$

Comments are closed.

Strongback Consulting