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.

November 22, 2010
Views: 36,881
PDF Download
  1. Select File > New > Project... from the main menu of Visual Studio.
    New project
  2. In the New Project window, select Class Library as the template, enter PhoneBook as the project name, and click OK.
    New class library project
  3. In the Solution Explorer, right-click on the PhoneBook project and select Open Visual Paradigm from the popup menu.
    Open Visual Paradigm
  4. Click OK when the Project Structure dialog box appears.
    Project Structure window
  5. 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.
    New class diagram
  6. Select Class from the diagram toolbar.
    Select class
  7. Click on the diagram to create a class, name it Book, and press Enter to confirm.
    Class created
  8. Right-click on the Book class and select Add > Attribute from the popup menu.
    New attribute
  9. Enter name : string and press Enter.
  10. Enter description : string and press Enter. Press Esc to confirm.
    Attributes added
  11. 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.
    To use Resource Catalog
  12. Release the mouse button. Select Association -> Class from the Resource Catalog to create the class.
    Create associated class
  13. Name the class Contact.
    Contact class created
  14. Right-click on the Contact class and select Add > Attribute from the popup menu.
  15. Enter name : string and press Enter.
  16. Enter age : int and press Enter.
  17. Enter phoneNum : string and press Enter. Press Esc to confirm.
    Attributes created
  18. Click Update Code in the Diagram Navigator. You can see that two code files have been generated.
    Update code
  19. Add an operation `printInfo` in the source code of the `Book` class.
    Operation added
  20. 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.
    UML model updated