Dialogue You can use UML diagrams to model your application's user requirements and design, making it easier to discuss the ...

Dialogue

You can use UML diagrams to model your application's user requirements and design, making it easier to discuss the application with your team and with stakeholders. This also helps to make sure the application meets the users' needs, resulting in better architecture, fewer bugs, more maintainable code, and lower total cost of development. 

Visual Studio provides an integrated environment where you can track the work alongside your models by linking Team Foundation Server work items to model elements. UML diagrams are partial views of the model, which live inside a modeling project that you can check into version control. This provides traceability between the models, the IDE, and the code, whether you are designing a new solution or updating an existing solution. 

You can create models iteratively to help you:
- Identify new or evolving requirements for the application.
- Create a layered architecture with suitable abstractions for an object-oriented approach.
- Develop the flow of control between components and classes.

Let's examine the modeling diagrams for the PetShop Web application so we can get a better understanding of its design and requirements.



Action
In Solution Explorer, expand the PetShopModeling project.

Open Order Use Cases.usecasediagram.

Dialogue
This use case diagram shows us the users and their goals for the system. These are represented by actors and use cases, respectively.




Action
In the PetShopModeling project, open Petshop Online.componentdiagram.

Dialogue
A component diagram describes the high-level structure of the system and the services that parts of the system use to communicate with each other. You can use this diagram to help you describe the system architecture along with layer diagrams and class diagrams. 

We previously refactored the code to comply with the layer diagram created by the team's architect to describe the intended architecture. However, our component diagram is missing the PaymentGateway component that we refactored our code to use. We think it's important to include this component on the diagram so our model reflects what we did, so we'll open a bug for this task.  



Action
From the Toolbox, add a comment and connect it to the Order Processing component. Add the text "we need to add the PaymentGateway component to the diagram"

Right-click the Order Processing component. Choose Create Work Item, Bug. 

Copy the comment text into the bug title. 

Save the bug.

Dialogue
As you can see, we can easily create a link between this component and a bug, so the person who fixes this bug can open the diagram directly from the bug. We're done with this task, so let's look at the next diagram.



Action
In the PetShopModeling project, open Shopping Cart Order Flow.activitydiagram.

Dialogue
Activity diagrams describe the dynamic behavior of a system.



Action
In the PetShopModeling project, open Order System.classdiagram.

Dialogue
Let's update this class diagram and add the PaymentProcessor class. We can reverse-engineer classes onto the diagram by dragging them from Solution Explorer. This adds classes to the model as well as the diagram.



Action
In Solution Explorer, under the PaymentGateway project, expand the PaymentProcessor.cs node.

Drag the PaymentProcessor class to the class diagram. The class is also added to the model as well as the class diagram.

Dialogue
As we've shown, UML diagrams can help you visually describe your applications and communicate their requirements and design to others. We've also shown how easily we can create and track work against the design because our models are integrated with the code and the Visual Studio development environment. To learn more, see our other videos in Visual Studio.