Overview of this Tutorial
In this tutorial, we will show you how to perform round-trip engineering of ANSI C++ with a given project file.
In order to complete this tutorial you must have Visual Paradigm installed. You also need to have basic knowledge in UML modeling with Visual Paradigm.
Generating ANSI C++ Code from Class Diagram
- Download Photo-Album-CPP.vpp. You can also find this file at the bottom of this tutorial, under the Resources section.
- Open the downloaded project file in Visual Paradigm.
- Open the class diagram Photo Album. You should see the class diagram below:
- There are few ways you can take to generate ANSI C++ code - generate code from diagram, from selected classes, or for the whole project. In this tutorial let's try to generate code for the whole project. Select Tools > Code > Generate C++ Code from the toolbar.
- In the Generate Code window, specify the Source Path. You can specify a path by clicking on the cell and then click on the ... to popup the file chooser for selecting a folder.
- Click OK to generate. Source files are generated to the output path specified.
Updating UML Class Model from ANSI C++
Once you have finished generating code, you can modify it with your IDE or with any text editor. When you've finished the modification, you can reverse the code-base back to the Visual Paradigm for an update of the UML class model. Let's have a try.
- Open the generated file Location.h in a text editor.
- Let's say we want to add two attributes for the coordinate (x and y) of the location. Let's add two private int attributes x and y.
- Save the changes.
- Let's update our UML model to reflect the change just made. Select Tools > Code > Reverse C++ Code... from the toolbar.
- Uncheck Reverse source on demand at the bottom of the Reverse Code window. If you keep it checked, the UML model won't be updated directly. Instead, an index tree will be formed from the source files specified in the source folder. We want our model updated, so let's uncheck it.
- Click OK. Now, the class diagram is updated and you should see the two private int attributes x and y added to the Location class.