Purpose

This tool mentor describes how to use Rational Rose® to reverse-engineer existing code into elements in the Artifact: Design Model.

Reverse engineering source code with Rational Rose requires a Rational Rose Language Support add-in that is compatible with that source code, such as Rose J (for Java) or Rose Visual C++.

Related Rational Unified Process activity: section "Reverse-engineer components and databases" in Activity: Incorporate Existing Design Elements.

Overview

Reverse engineering is the process of examining an existing source or binary code project to recover information about its design, then using that information to generate or update a model representing the project's logical structure. A code project corresponds to a component in the component view of a model. Reverse engineering is performed between the project or source file and the target model.

You can use Rational Rose to reverse-engineer existing code into a design model in three ways:

For detailed information about reverse-engineering see the Rational Rose online help. Among the add-ins that support reverse-engineering are:

  • Rose Ada

  • Rose Corba

  • Rose Data Modeler

  • Rose J (for Java)

  • Rose XML DTD

  • Rose Visual C++

  • Rose Visual Basic

  • Rose Web Modeler

1. Create a New Model by Reverse-engineering code To top of page

In this case, you are starting with an existing implementation that you bring into your model. When you reverse-engineer existing source, you use the Rational Rose Tools menu to select the appropriate language or data base add-in. When reverse-engineering is complete, you can create the diagrams you use to visualize your project and further develop the model.

2. Update an Existing Model by Reverse-engineering code To top of page

In this case, you have an existing model and you're introducing source code to reflect existing implementation. As you develop the model and source, you can continue to update the model with your changes.

3. Add External Components to a Model To top of page

External components are classes that are not implemented in your application. Instead, they are referenced or are sub-classed by model classes and by code implemented in your application, such as COM objects, or Microsoft®Foundation Classes (MFC).

Because they are not implemented in your application’s code, only their interface and internal documentation are reverse engineered. This limited form of reverse engineering is called Importing.

Note: This process should be restricted to components that are external to the model, or that will be sub-classed in the model. External classes should have their Generate Code flag set to false.

To access objects from your model, simply drag and drop them (.dll, .exe, .ocx, or .tlb) from the Explorer into an open component diagram, a component package, or onto a logical package in the browser.

  • If the drop target is a component package or one of its diagrams, the new component will belong to that package. Otherwise, the new component is added to the top-level of the Component View and to the main component diagram.

  • A logical package with the same name as the new component is created in the logical view. The new logical package contains the interface elements that are provided by the corresponding software module. The interface of the new component can now be used by the classes in the model.
  • If the drop target is a logical package or one of its diagrams, the logical package for the new component is added to that package.

Note that two conditions must be met before you can drag-and-drop a COM object into your model:

  • The TypeLibImporter add-in must be loaded and activated

  • The selected COM object file must either be a properly registered TypeLib (.tlb) or must contain a TypeLib.

If both of these conditions are not met, the drop into the model is ignored.

4. Packaging and Diagramming Reverse-Engineered Classes To top of page

When Rational Rose reverse engineers or imports code information, it assigns the resulting model data to a package (with the same name as the project) under the Reverse Engineered package, or to an MFC package, as appropriate. Diagramming these components, or adding them to other packages, is left up to you.

Diagramming Reverse-Engineered projects

Diagramming a model is a very subjective process. For this reason, the reverse engineering process generates model data only. It does not generate model diagrams. You can add classes to a diagram in either of two ways:

  • Drag-and-drop classes from the browser to an open diagram.

  • Add one or more classes, by name, to the active diagram using the Add Classes dialog box (from the Query menu, select Add Classes)

Arrange the diagrammed components to illustrate the architecture of the system. Avoid crossed association lines by moving the classes in the diagram. You can use the Diagram Object Properties command on the Edit menu to control the level of class details in a diagram.

Dropping Classes into a Diagram

    You can add a class to a diagram simply by opening the diagram, then dragging and dropping the individual classes from the browser into the diagram.

The Add Classes Dialog Box

You can use the Add Classes dialog box to move classes from a package to the active diagram. The selected classes are added to the active diagram. Arrange the added classes to best illustrate the architecture of the system.

Adding Reverse-Engineered Classes to Packages

While you may leave your new classes in their reverse-engineered project package, can also move or copy them to other packages in your system. There are four ways to move a class from one package to another:

  • Drag-and-drop the class from the Reverse Engineered package to the one you want it in.

  • Open a class diagram that contains the destination package, then drag-and-drop the class from the Reverse Engineered package to the one you want it in.
  • Create a new class in your package diagram with the same name as the reverse-engineered one, select this new class, then choose Relocate from the Edit menu to move the class.
  • Cut or Copy, then Paste the class from the Reverse Engineered package to the one you want it in.

Copyright  ⌐ 1987 - 2000 Rational Software Corporation

Display Rational Unified Process using frames

Rational Unified Process