C# Round-trip Engineering
Visual Paradigm's Visual Studio integration enables you to design your system with class diagram and generate code. On the other hand, you can update changes made in code back to the model. This makes sure both the design and source code are updated.
- Select File > New > Project... from the main menu of Visual Studio.
- In the New Project window, select Class Library as the template, enter PhoneBook as the project name, and click OK.
- In the Solution Explorer, right-click on the PhoneBook project and select Open Visual Paradigm from the popup menu.
- Click OK when the Project Structure dialog box appears.
- From the Diagram Navigator, right-click on the Class Diagram node and select New Class Diagram from the popup menu. This creates a blank class diagram.
- Select Class from the diagram toolbar.
- Click on the diagram to create a class, name it Book, and press Enter to confirm.
- Right-click on the Book class and select Add > Attribute from the popup menu.
- Enter name : string and press Enter.
- Enter description : string and press Enter. Press Esc to confirm.
- A phone book contains many contacts. Let's create a Contact class from the Book class with an association. Move the mouse pointer over the Book class. Press on the Resource Catalog icon and drag it out.
- Release the mouse button. Select Association -> Class from the Resource Catalog to create the class.
- Name the class Contact.
- Right-click on the Contact class and select Add > Attribute from the popup menu.
- Enter name : string and press Enter.
- Enter age : int and press Enter.
- Enter phoneNum : string and press Enter. Press Esc to confirm.
- Click Update Code in the Diagram Navigator. You can see that two code files have been generated.
- Add an operation `printInfo` in the source code of the `Book` class.
-
Right-click on the code editor and select Update UML Model from the popup menu.
You can see that the `printInfo()` operation is added to the `Book` class on the UML model side.