About a year ago I had to stop work on an interesting project. There were just too many projects going on at one time, not enough resources to work on them all, and the other projects were more important from a political point of view. The project involved our B2B application making a call to a service provided by a 3rd party outside the firewall. One of the developers had built some great Java code to do this right before we stopped work.
I recently picked that project back up again and needed to dig into that code, understand how it worked, and create some design documentation for the overall project. I also had just recently made a conscious effort to upgrade my object modeling tool from Rational XDE to Rational Software Architect (RSA).
I decided I would start by reverse engineering the Java code to create a class diagram. I had done this numerous times as a Rational Rose and Rational XDE user in the past so I had no worries. I managed to import the source code and began fumbling through the menu options looking for reverse engineering features. I got a sinking feeling at first that someone at Rational had taken the reverse engineering features away. I found numerous transformations for forward engineering from UML class diagrams into something else (like Java). It was not obvious, however, what to do if I already had the Java code and wanted to go in the reverse direction. I had a sinking feeling inside. Had the Model Driven Development / Model Driven Architecture adherents at Rational lost their minds? Had they taken those reverse engineering features away on purpose? Was this a heavy handed means of forcing the whole world to adopt a “forward engineering only” view of the application development process?
Luckily, I was able to determine that Rational had not lost its collective mind. Yes, it was indeed possible to reverse engineer code into a diagram and as I got more into it, I decided it was actually an improvement.
I highly recommend a meaty white paper I found on developerWorks called “The new IBM Rational design and construction products for Rose and XDE users” by William T. Smith, a Product Manager supporting model driven development at IBM Rational brand software. From it I discovered that many reverse engineering capabilities were available in RSA (as well as Rational Software Modeler (RSM)) and they appear to be significant improvements over what I was used to in Rose and XDE. There is a great deal of new terminology to get used to, however.
Here is a quick summary of what I learned about reverse engineering using RSA
- I can select Java classes of interest with my mouse and quickly reverse engineer a class diagram by “visualizing” a “Topic Diagram”. This diagram can be synchronized with code as the code is modified.
- I can “harvest” classes from the topic diagram and paste them into a separate UML diagram.
- I can mix “pure” UML classes and harvested classes on the same diagram and the tool will mark classes reverse engineered from code with a glyph in the upper left hand corner.
- There is a new “Browse Diagram” capability which allows the user to explore existing code by quickly generating class diagrams “on the fly” showing classes related to a selected class. Selecting a different class on this diagram will generated yet another diagram on the fly with all classes related to that class. This quick navigation from one diagram to another is a great way to “get to know” code someone else wrote. You can control which kinds of relationships are included when the class diagrams are created and how many levels (up to 3) removed from the selected class in the center of the diagram. I made great use of this on my project.
- (Drum roll please!) I can reverse engineer Java method bodies into UML Sequence Diagrams by “visualizing” a “Static Method Sequence Diagram.” This type of program understanding tool has long been missing from UML modeling tools. It will be a windfall to any poor soul who must maintain/modify poorly documented Java code created by someone else who is perhaps no longer around. The only downside is that if the method makes any calls to low-level Java classes like “Integer” those method calls will clutter the generated diagram. But.. think of the time you’ll save!
Together, these reverse engineering capabilities will just about take away the last excuses for not having design documentation match the “as implemented” state of the Java code. It really is easy to create both class and sequence diagrams and rapidly document both the static and dynamic behavior of “as is” Java software.
(Dec 2007) English not your native language? I've begun making podcasts of popular posts and they are available at http://artsciita.podbean.com/. Listen online at that URL, with the MP3 player below, or subscribe to the podcast using the RSS feed and listen with your favorite MP3 player.
The postings on this site are my own and don't necessarily represent IBM's positions, strategies, or opinions.