SDE for Visual Studio UML CASE Tool Tutorial - Introduction to Visual Studio UML Tool

Chapter 1  Introduction

 

In this chapter, you will learn how to work with the SDE environment in Visual Studio® .NET, and you will have a first taste of the powerful functionalities of SDE including code reverse engineering, code generation and code/model synchronization.

 

 

In this chapter:

*      Working with SDE for Visual Studio®

*      Code Reverse Engineering

*      Code Generation

*      Code Synchronization

 


Working with SDE for Visual Studio®

1.        Start Visual Studio® .NET, then select Tools menu > VP-SDE VS to start SDE.

2.        After SDE has loaded, you will see the working environment changed as in the screen below.

 

 

3.        Select File menu > Open > Project... to open the sample project "School.csproj".


4.        After the project is opened, you will see the SDE user interfaces are activated. Let's have a glance at the SDE environment.

SDE Toolbars

Provide quick access to SDE's frequently used functionalities

Diagram Tree

Displays diagrams in the project categorized by diagram types

Model Tree

Displays model elements in the model repository

Class Repository Tree

Displays packages/classes in the model repository

Property Pane

Displays context-sensitive properties of selected elements

Preview Pane

Displays the overview of the active diagram

Documentation Pane

Displays the documentation associated with the selected element

Element Viewer

Displays detailed information about specific kind of elements (such as attributes/operations of a class)

Message Pane

Displays SDE information/warning/error messages

 

5.        All the SDE panes behave like standard Visual Studio® .NET panes, can be dragged and docked to any positions.


6.        You can save your favorite UI perspective by selecting the Tools menu > Save Perspective/Save Perspective as..., or select the Tools menu > Manage Perspectives... to manage or apply existing perspectives.

 

To see the interactive tutorial of this section, please click here.

 

Code Reverse Engineering

1.        Start Visual Studio® .NET and start SDE. After that, open the sample project "School.csproj".

2.        Right-click on the "School" project node in the Solution Explorer and select Update UML Model from the popup menu.


3.        Activate the Model Tree and you will see the reversed classes.

4.        Right-click on the package "Sch" and select the Form Diagram menu > Customize....

5.        When the Form Diagram dialog box appears, enter "School Class Diagram" in Diagram Name, and select the option Show all levels in single diagram. After that, click OK to generate the diagram.


6.        A class diagram will be generated as shown below.

 

To see the interactive tutorial of this section, please click here.

 

Code Generation

1.        Start Visual Studio® .NET and start SDE. After that, open the sample project "SchoolForCodeGen.csproj".

2.        Activate the diagram "School Class Diagram", resize the package "Sch" to make room for new classes.

3.        Create a class named "Student" and place it inside the package "Sch".

4.        Right-click on the new class and select New Attribute from the popup menu.

5.        Enter "-name : string" to add a private attribute ("-" is UML notation for private visibility) named "name" with type "string". After that, press the Enter key to confirm.

6.        With the attribute "name" still selected, press the Insert key to add another attribute. Enter "-studentID : string" to add a private attribute named "studentID" with type "string".

7.        Right-click on the class "Student" and select New Operation from the popup menu.

8.        Enter "+setName(name: string) : void" to add a public operation ("+" is UML notation for public visibility) named "setName", it accepts a parameter "name" of type "string", and its return type is "void".

9.        Follow the previous steps to add a getter method for "name", this time we enter "+getName() : string" to add a public operation named "getName" whose return type is "string".

 


10.     Right-click on the project node "SchoolForCodeGen" in the Model Tree and select Update All to Code from the popup menu.

11.     The source code for the class "Student" will be generated with the content as defined in the class diagram.

 

To see the interactive tutorial of this section, please click here.

 

Code Synchronization

1.        Start Visual Studio® .NET and start SDE. After that, open the sample project "SchoolForCodeSync.csproj".

2.        Activate the diagram "School Class Diagram", right-click on the class "Teacher" and select Browse Code from the popup menu to open its source file.


3.        Double-click on the class "Teacher" and rename it to "Instructor".                              

4.        Right-click on the class "Instructor" and select Update to Code to update the change to the source code.

5.        You will see the change in the class diagram is now reflected in the source code.

6.        Edit the class "Instructor" in the text editor to change the visibility of the attribute "name" to "protected", and change its initial value from "null" to "unnamed".


7.        Edit the method body of "setName" so that it checks the value of the "name" parameter before assigning the new value to the attribute (as shown in the figure below).

8.        Right-click on the text editor of "Teacher.cs" and select Update UML Model from the popup menu to update the changes to the class model.

9.        The change that you have just made to the class "Instructor" is reflected in the class diagram (except the change of the "setName" method body, which is not displayed in the class diagram).

10.     Select the "setName" operation of the class "Instructor" in the class diagram, press F2 to edit it.

11.     Replace the "+" sign to "-" sign to make this operation private, and change the return type from "string" to "bool". After that, press Enter to confirm.


12.     Right-click on the class "Instructor" and select Update to Code to update the changes to the source code.

13.     With the help of SDE's incremental code synchronization, the method declaration of "setName" is updated, while the method body remains unchanged.

 

 

To see the interactive tutorial of this section, please click here.

 

Patents pending. All rights reserved.