Reverse Engineering Source Code

3 4

Even if coding is under way, you can use UML diagrams to better understand a project. If you develop projects in Microsoft Visual C++ 6 or Microsoft Visual Basic 6, you can reverse engineer your projects' class definitions and generate UML static structure models in the Model Explorer. Visio includes the Microsoft Visio UML Add-In, which you can run from within Visual C++, and the Microsoft Visio UML Visual Basic Add-In, which you can run from within Visual Basic. Each add-in provides a toolbar similar to the one shown in Figure 20-16. With the toolbar buttons, you can open Visio and start a new diagram based on the UML Model Diagram template from within Visual C++ or Visual Basic as well as reverse engineer source code. After you reverse engineer a project, you can create a class diagram in Visio by dragging elements from the static structure model onto the drawing page.

figure 20-16. the uml add-in adds a toolbar to visual c++ and visual basic. in visual basic, the visio uml options button does not appear.

Figure 20-16  The UML add-in adds a toolbar to Visual C++ and Visual Basic. In Visual Basic, the Visio UML Options button does not appear.

Note


The first time you install Visio, you must start it and exit it at least once before you can reverse engineer code. In addition, Microsoft Visual Studio Service Pack 3 must be installed to reverse engineer code.

InsideOut


Microsoft extends the reverse engineering capabilities of the UML Model Diagram template with Visual Studio.NET, which can reverse engineer code from Visual Basic 7, Visual C++ 7, and C#. In addition, Visual Studio.NET Enterprise Edition can generate code skeletons for Visual C++ 6 and later and Visual Basic 7. The UML features in Visual Studio.NET replace the functionality provided by Visio 2000 Enterprise Edition, which is no longer supported.

Reverse Engineering Visual C++ 6 Source Code

When you reverse engineer a Visual C++ project, you must first customize Visual C++ with the Visio UML add-in. Your Visual C++ project must include a browse information file, which the Visio UML add-in uses to create a model in Visio. The Visio UML add-in can reverse engineer the following C++ language constructs: classes, user-defined types, enumerated types, member functions, member variables, and method parameters.

Follow these steps to customize Visual C++ code so you can reverse engineer it:

  1. In Visual C++, choose Tools, Customize.
  2. In the Customize dialog box, click the Add-Ins And Macro Files tab.
  3. In the Add-Ins And Macro Files list, select Visio UML Add-In.
  4. Click Close to add the floating Visio UML Add-In toolbar.
  5. If you don't already have a browse information file for a project, open the project, and then choose Project, Settings.
  6. In the Project Settings dialog box, choose the type of build configuration you want, click the C/C++ tab, and then select Generate Browse Info.
  7. Click the Browse Info tab to specify the name and location of the browse information file, select Build Browse Info File, and then click OK.

Follow these steps to reverse engineer Visual C++ 6 source code:

  1. Build the project in Visual C++.

    Tip


    Make sure your project includes header files for your classes. If your project doesn't have a header file for a class, that class will not appear in the model that Visio reverse engineers.

  2. In Visual C++, click the Reverse Engineer UML Model button on the Visio UML Add-In toolbar.

    Note


    If more than one project exists in the Visual C++ workspace, in the Select Project dialog box, select the project you want to reverse engineer, and then click OK. If more than one browse information file appears in the project hierarchy, in the Select Browse File dialog box, select the file you want to use, and then click OK.

    Visio opens a blank static structure diagram drawing page and the Model Explorer, which is populated with elements that reflect the class definitions in the source code.

  3. To create a static structure diagram, drag elements from the Model Explorer onto the blank static structure diagram drawing page.

Troubleshooting

Some elements of the C++ project were not reverse engineered correctly.

Visio creates a model based on the contents of a browse information file, which can include errors. According to Microsoft, the browse information file API has several known bugs that affect its ability to handle C++ templates. Because of this limitation, long parameter lists are not always reverse engineered, and class names and class method names are sometimes corrupted, which causes Visio to ignore them or sometimes add the corrupted name to the UML model. Visio creates a log file of errors detected during the reverse engineering process and saves the file in the system temporary folder with the name of the project; for example, C:\WINNT\Temp\project.txt).


Reverse Engineering Visual Basic 6 Source Code

To reverse engineer Visual Basic source code, you must load the Microsoft Visio UML Visual Basic Add-In into Visual Basic. The add-in displays the Microsoft Visio UML Solution toolbar and adds the Microsoft Visio UML Solution menu to the Tools menu; both the toolbar and the menu will continue to appear every time you open Visual Basic. The UML add-in can reverse engineer the following Visual Basic language constructs: classes, modules, and forms; functions and subroutines; parameters; constants; member variables; properties; events; and user-defined types.

Follow these steps to customize Visual Basic so you can reverse engineer Visual Basic 6 code:

  1. In Visual Basic, choose Add-Ins, Add-In Manager.

  2. Select Microsoft Visio UML Visual Basic Addin. For Load Behavior, select the Loaded/Unloaded and Load On Startup check boxes, and then click OK.

    Note


    You need to set up the add-in in the Add-In Manager only once.

  3. Open the project that contains the source code you want to reverse engineer.
  4. In Visual Basic, click the Reverse Engineer UML Model button on the Visio UML Solution toolbar.

    Visio opens a blank static structure diagram drawing page and the Model Explorer, which is populated with elements that reflect the class definitions in the source code.

  5. To create a static structure diagram, drag elements from the Model Explorer onto the blank static structure diagram drawing page.



Microsoft Visio Version 2002 Inside Out
Microsoft Visio Version 2002 Inside Out (Inside Out (Microsoft))
ISBN: 0735612854
EAN: 2147483647
Year: 2000
Pages: 211
Authors: Nanette Eaton

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net