Tech News‎ > ‎

UML Reverse Engineering for Existing Java, C# & VB Code

posted Dec 5, 2010, 4:58 AM by Shaukat Mahmood Ahmad   [ updated Dec 5, 2010, 5:02 AM ]

UML Reverse Engineering for Existing Java, C# , and Visual Basic .NET Code

Altova UModel® 2011 imports Java, C#, and Visual Basic .NET source code and binary files, and generates UML diagrams to facilitate analysis, enhancement, or reuse.

Hand-written or legacy source code can be difficult to decipher, since operability of the software does not depend on complete or accurate documentation, or even on a well-structured code body. Further, some projects incorporate binary or byte-code files that also require analysis. The original developer may no longer be available, or maybe development was assigned in pieces and no single individual knows the entire project. 

Altova UModel® 2011 includes a powerful reverse engineering capability to read Java 1.4, Java 5.0, Java 6.0 C# 1.2, C# 2.0, C# 3.0, C# 40, VB 7.1, VB 8.0, or VB 9.0 source code and binary files, and generate UML models for a visual representation that is much clearer and more easily analyzed than a printout of the source as text. 

Like other UModel® 2011 features and operations, reverse engineering offers many options to adapt to the way you want to work, instead of forcing you to use a particular paradigm. The UModel® 2011 Project menu offers Import options for source code and binary files:

Altova UModel project menu

Reverse Engineer Source Code

UModel® 2011 can import Java source code files from JBuilder, Eclipse, and NetBeans projects, C# source code from Microsoft Visual Studio and Borland C#, and Visual Basic .NET project files.

Altova UModel import dialog

You can import a single directory, a directory tree, or an entire project, and you can choose to merge the imported code into an existing UModel® 2011 project, or create a new one. 

You can apply reverse engineering to model an existing application. Or, you can get a new project off to a quick start by importing class libraries such as employee, customer, vendor, and other classes that are already known to your organization.

Altova UModel reverse engineering messages

As UModel® 2011 reverse-engineers your selection, the message window displays progress. UModel® 2011 can be set to automatically open the diagrams after the files process, and tabs below the view window will give you easy access to any diagram you want.

If you import Java source code that has accompanying JavaDocs, the UModel® 2011 documentation window can be optionally populated for each UML diagram. Similarly, C# and Visual Basic .NET DocComments can also be imported as documentation for your model project.

UModel® 2011 reverse engineering of Visual Basic .NET code is line-oriented and case-insensitive (so Class1, CLASS1, class1, ClAsS1 are considered as identical), consistent with looser Visual Basic .NET naming requirements.

UModel automatically resolves namespace or class aliases during reverse engineering. Later, when you update the code from your model after enhancements have been added, the correct alias definitions are again inserted.

The UModel® 2011 Hierarchy helper window offers a quick view of generalization and inheritance relationships that can assist in your analysis of the reverse engineered application. You can click the Hierarchy tab to view the relationships of a class selected in any class diagram or in the Model Tree.

Altova UModel reverse engineering Hierarchy window

Generate Sequence Diagrams After Reverse Engineering

UModel® 2011 lets you generate sequence diagrams from source code files that have been reverse engineered into UML classes. The resulting sequence diagrams can be an invaluable aid to assist analysis of complex interactions.

UML sequence diagram

Click image to enlarge screenshot

The Sequence Diagram Generation dialog offers options to create lists of types and operation names that will not appear in your generated diagram, and to automatically split very large sequence diagrams and hyperlink them for convenient navigation.

Altova UModel sequence diagram generation dialog

Click here to visit the UModel sequence diagrams page for more information on generating sequnce diagrams from reverse engineered code.

Reverse Engineer Binary Files

UModel® 2011 can import Java, C#, and Visual Basic .NET binary files. For Java, type import is supported for all class archives adhering to the Java Virtual Machine Specification. For C#, type import is supported for assemblies targeting the .NET Framework and .NET Compact Framework for PocketPC, Smartphone, and WindowsCE. For Visual Basic .NET, DLLs and EXEs from the filesystem, or an assembly from the global cache (GAC) or from a MSVS.NET reference can be imported. 

(In order to import binary files, the appropriate Java, C#, or Visual Basic runtime environment, development kit, or .NET framework must be installed.) 

After selecting Import Binary Types from the Project menu, you can select various options from the Import Binary dialog:

Altova UModel binary import

Additional selections may be available, depending on the requirements of the specific binaries you select. The UModel® 2011 integrated Help system can guide you through all the details of importing binary files.

Altova UModel reverse engineering binary file selection

Click image to enlarge screenshot

You can choose to hyperlink elements to diagrams and generate package dependency diagrams to embed more explicit cross referencing within the UML model. You can also instruct UModel to automatically open diagrams generated through reverse engineering. 

Successful import of a large binary project will create numerous entries in the Model Tree.

Altova UModel model tree

When you open a diagram and select any element, it is highlighted in the Model Tree to aid in navigation and analysis.

Altova UModel reverse engineering model tree

Click image to enlarge screenshot

If you make revisions or enhancements to the models of binary files, UModel® 2011 lets you generate new source code to implement the changes. Simply open the Model Tree and select the component for the reverse-engineered binary. In the Properties window for the component, check the box labeled “use for code engineering,” and assign a directory.

Altova UModel properties helper window

When you choose Overwrite Program Code from the Project menu, UModel® 2011 will write new source code for the model you originally created from binary files. 

Of course whether you reverse engineer source code or binary files, the UML diagrams are presented with all the same UModel® 2011 syntax coloring, entry helpers, and quick editing buttons as UML diagrams you draw yourself.