UML Sequence Diagrams: Reference

Visual Studio Ultimate enables users to create sequence diagrams, which depict interactions between instances of various classes, components, subsystems, or actors. These diagrams display the flow of messages between participants over time and illustrate the control's direction from one party to another. To generate a UML sequence diagram, follow these steps:

1. Access the Architecture menu in Visual Studio Ultimate.

2. Click on New Diagram.

The resulting diagram showcases example instances and events instead of classes and methods. It is possible for multiple instances of the same type to appear in the diagram, as well as for multiple occurrences of the same message to be displayed simultaneously.

There are two types of sequence diagrams available in Visual Studio:

The first kind of sequence diagram displays only one instance of each class, whereas the second kind allows more than one instance of each element to be present. The properties of these elements may vary slightly between the two types, although they share many similarities.

For comprehensive instructions on creating and designing modeling diagrams in UML, refer to Microsoft Docs: How to: Edit a UML Model and Diagrams.

This table presents the elements that can be found on a sequence diagram. For more details about these components, please refer to the Properties of Elements in UML Sequence Diagrams and the UML Sequence Diagrams: Guidelines sections.

Element| Description

---|---

1| Lifeline

2| Actor

3| Synchronous Message

The lifeline is represented by a vertical line that shows the sequence of events that occur over time in a participant during an interaction. This participant can be an instance of a class, component, or actor. To indicate that an actor is involved in the interaction, you can set its Actor property at the top of the lifeline.

Synchronous messages are used to represent ordinary function calls within a program, as well as other kinds of message that behave in the same way. The sender of a synchronous message will wait for a response before continuing. The diagram will include both the call and return.

以下是重构后的段落结构:

1. 异步消息(Asynchronous message)

- 描述:无需等待发送者继续,即可发送的消息。展示的只是发送者的调用。用于表示不同线程之间的通信或创建新线程。

2. 执行发生(Execution occurrence)

- 描述:在参与者的生命线上出现的一个垂直阴影矩形,表示参与者正在执行操作的时间段。

- 解释:执行从接收到消息的那一刻开始。如果发起的消息是同步消息,执行将在使用“返回”箭头返回发送者时结束。

3. 回调消息(Callback message)

- 描述:返回给等待先前调用返回的消息的参与者的消息。产生的执行发生将出现在现有执行发生的上方。

4. 自引用消息(Self message)

- 描述:来自参与者自身的消息。产生的执行发生将出现在发送执行的上方。

5. 创建消息(Create message)

以下是根据您提供的内容重构的段落结构:

在UML序列图中,有四种主要的消息类型:创建参与者消息、发现消息、丢失消息和注释。这些消息类型分别具有不同的功能和用途。

1. 创建参与者消息:当一个参与者收到创建消息时,它应该是收到的第一条消息。这种消息通常用于初始化或启动一个过程。

2. 发现消息:这是一种来自未知或未指定参与者的异步消息。发现消息可以帮助参与者识别其他参与者,并建立联系。

3. 丢失消息:这是一种发送给未知或未指定参与者的异步消息。丢失消息可能表示参与者之间的连接中断,需要采取措施修复。

4. 注释:注释可以附加到任何生命线上的任意点。它可以用来提供关于某个过程或组件的额外信息。

5. 交互使用:这是一种包含在另一个图表中定义的消息序列。要创建交互使用,只需点击工具栏上的图标,然后将鼠标拖动到要包含的生命线上。

6. 组合片段:这是一组片段的集合。每个片段可以包含一个或多个消息。组合片段有不同的种类。有关更多信息,请参阅在UML顺序图中使用片段描述控制流 。要创建一个片段,只需右键单击一条消息,选择“包围”,然后单击一个片段类型。

7. 片段守卫:这可以用于声明与片段是否发生相关的条件。片段守卫有助于确保在满足特定条件的情况下才执行片段中的操作。

This is a refactored version of the content:To set the guard in the UML sequence diagram, you need to select a fragment and then choose the guard, followed by entering a value.

Destruction Event

The Destruction Event represents the point at which an object is deleted or becomes no longer accessible. It typically appears towards the bottom of each lifeline in the UML sequence diagram.

Interaction

An Interaction consists of messages and lifelines that are displayed together in a sequence diagram. In order to view the properties of an Interaction within the UML Model Explorer, you must first select it.

Sequence Diagram

A Sequence Diagram is a visual representation of an Interaction. To access its properties, simply click on any blank area of the diagram.

Note

The names of the Sequence Diagram, the Interaction it represents, and the file containing the diagram can all be different.

See Also

Concepts

Change History

Date

History

Reason for creation

August 2011

Added description for what destruction event means at the end of a lifeline and included customer feedback.