Reverse Engineering Source Code to Model and Diagrams

The Reverse Engineering tool helps you create new diagrams for the projects with existing source codes in no time. You can select the projects, folders, or files to generate UML class diagrams, package diagrams, and entity-relation diagrams. The tool allows you to create new diagrams or updated diagrams that were already created by a source code.

Code to UML

Source code can be transformed into UML diagrams using reverse engineering tools in Software Ideas Modeler. Classes from various supported programming languages can be turned into UML class diagrams where the class elements are connected with appropriate relationships (such as generalization, association, etc.). The UML generator can also produce package diagrams based on packages and namespaces defined in the source code files. The code to UML transformation supports new diagram creation as well as update of existing diagrams.

Code to ERD

The reverse engineering feature includes entity-relationship diagram generation. The classes in the source code can be turned into ERD entities. During code to ERD transformation, unsupported items will be omitted, e.g. operations that are not supported by the ERD notation.

How to Create Diagrams from Code

The reverse engineering feature is available in:

  • Ribbon / Process tab / Reverse Engineering group / Source Code
  • Menu / Tools / Reverse Engineering / Source Code
Reverse Engineering / Source Code
Reverse Engineering / Source Code

The action will open the Source Code Import dialog that helps you to reverse engineer your source code into a diagram or a set of diagrams. The dialog offers two tabs: General and Settings.

General Tab

In the General tab, you can choose a programming language (C#, C++, Dart, Java, JavaScript, Object Pascal, PHP, Python, Ruby, SQL DDL, Visual Basic) that is used in the source code you want to process. The tab offers various options on how to choose the source code files. You can import the files by a project file (only for some programming languages). The other options are available for all programming languages - you can add individual files with the source code using the Add Files button or add all the files from a chosen folder using the Add Directory button.

The three other buttons Select All, None, and Invert allow you to adjust which files from the list you want to process. This way, you can load all files from a project to the list but choose only some of them to import into the model.

Reverse Engineering Settings

The Settings tab offers other options which are essential in adjusting the output of reverse engineering.

Source Code Import - Settings tab
Source Code Import - Settings tab

The Objects group allows you to choose which types of entities you want to import. You can pick from several entity types:

  • Classes - to generate UML class diagrams from code
  • Packages - to generate UML package diagrams from code
  • ERD entities - to generate ERD diagrams.

The group Diagramming includes settings for the diagram output configuration. If the option 'Add new elements to diagram' is checked, the new elements will be added to a new diagram. Otherwise, only the models will be imported. (You can manually insert the elements into your diagrams later.)

You can choose a target folder for the new diagrams. Click on the button with the ellipsis to select the folder from the project tree.

The option 'Create hierarchy by namespace' activates the automatic creation of subfolders by the namespaces/packages in the source project.

In the Model group, you can configure how to process the changes in the project model. There are the following options:

  • Update existing elements - if the elements were already imported, their model will be updated according to the changes in the source project. If this option is unchecked, the new version of the element will be imported as a separate element.
  • Delete missing elements - if the element that was already imported is not present in the source project anymore, it will be removed during the processing.

Repository for model elements - allows you to choose a project repository (project, folder, diagram), in which will be the new elements imported.

  • Default repository - the target folder for the diagram will be used as the model repository. If it is not defined, the first folder in the project will be used instead.
  • Custom repository - you can click on the ellipsis button to choose the repository in the project tree.

After clicking on the OK button, reverse engineering will process the source project by the settings (the new elements will be added to the model, some elements can be updated, the new diagrams can be created). You can also undo the action later.

New Comment

Comment