UML 2----Sequence Diagram

Sequence Diagrams
A sequence diagram is a form of interaction diagram which shows objects as lifelines running down the page, with their interactions over time represented as messages drawn as arrows from the source lifeline to the target lifeline. Sequence diagrams are good at showing which objects communicate with which other objects; and what messages trigger those communications. Sequence diagrams are not intended for showing complex procedural logic.

 

1. Detail description

 

Lifelines
A lifeline represents an individual participant in a sequence diagram. A lifeline will usually have a rectangle containing its object name. If its name is "self", that indicates that the lifeline represents the classifier which owns the sequence diagram.

Sometimes a sequence diagram will have a lifeline with an actor element symbol at its head. This will usually be the case if the sequence diagram is owned by a use case. Boundary, control and entity elements from robustness diagrams can also own lifelines.

Messages
Messages are displayed as arrows. Messages can be complete, lost or found; synchronous or asynchronous; call or signal. In the following diagram, the first message is a synchronous message (denoted by the solid arrowhead) complete with an implicit return message; the second message is asynchronous (denoted by line arrowhead), and the third is the asynchronous return message (denoted by the dashed line).

Execution Occurrence
A thin rectangle running down the lifeline denotes the execution occurrence, or activation of a focus of control. In the previous diagram, there are three execution occurrences. The first is the source object sending two messages and receiving two replies; the second is the target object receiving a synchronous message and returning a reply; and the third is the target object receiving an asynchronous message and returning a reply.

Self Message
A self message can represent a recursive call of an operation, or one method calling another method belonging to the same object. It is shown as creating a nested focus of control in the lifeline’s execution occurrence.

Lost and Found Messages
Lost messages are those that are either sent but do not arrive at the intended recipient, or which go to a recipient not shown on the current diagram. Found messages are those that arrive from an unknown sender, or from a sender not shown on the current diagram. They are denoted going to or coming from an endpoint element.

Lifeline Start and End
A lifeline may be created or destroyed during the timescale represented by a sequence diagram. In the latter case, the lifeline is terminated by a stop symbol, represented as a cross. In the former case, the symbol at the head of the lifeline is shown at a lower level down the page than the symbol of the object that caused the creation. The following diagram shows an object being created and destroyed.

Duration and Time Constraints
By default, a message is shown as a horizontal line. Since the lifeline represents the passage of time down the screen, when modelling a real-time system, or even a time-bound business process, it can be important to consider the length of time it takes to perform actions. By setting a duration constraint for a message, the message will be shown as a sloping line.

Combined Fragments

It was stated earlier that sequence diagrams are not intended for showing complex procedural logic. While this is the case, there are a number of mechanisms that do allow for adding a degree of procedural logic to diagrams and which come under the heading of combined fragments. A combined fragment is one or more processing sequence enclosed in a frame and executed under specific named circumstances. The fragments available are:
  • Alternative fragment (denoted “alt”) models if…then…else constructs.
  • Option fragment (denoted “opt”) models switch constructs.
  • Break fragment models an alternative sequence of events that is processed instead of the whole of the rest of the diagram.
  • Parallel fragment (denoted “par”) models concurrent processing.
  • Weak sequencing fragment (denoted “seq”) encloses a number of sequences for which all the messages must be processed in a preceding segment before the following segment can start, but which does not impose any sequencing within a segment on messages that don’t share a lifeline.
  • Strict sequencing fragment (denoted “strict”) encloses a series of messages which must be processed in the given order.
  • Negative fragment (denoted “neg”) encloses an invalid series of messages.
  • Critical fragment encloses a critical section.
  • Ignore fragment declares a message or message to be of no interest if it appears in the current context.
  • Consider fragment is in effect the opposite of the ignore fragment: any message not included in the consider fragment should be ignored.
  • Assertion fragment (denoted “assert”) designates that any sequence not shown as an operand of the assertion is invalid.
  • Loop fragment encloses a series of messages which are repeated.
The following diagram shows a loop fragment.

There is also an interaction occurrence, which is similar to a combined fragment. An interaction occurrence is a reference to another diagram which has the word "ref" in the top left corner of the frame, and has the name of the referenced diagram shown in the middle of the frame.

Gate
A gate is a connection point for connecting a message inside a fragment with a message outside a fragment. EA shows a gate as a small square on a fragment frame. Diagram gates act as off-page connectors for sequence diagrams, representing the source of incoming messages or the target of outgoing messages. The following two diagrams show how they might be used in practice. Note that the gate on the top level diagram is the point at which the message arrowhead touches the reference fragment - there is no need to render it as a box shape.

Part Decomposition
An object can have more than one lifeline coming from it. This allows for inter- and intra-object messages to be displayed on the same diagram.

State Invariant / Continuations
A state invariant is a constraint placed on a lifeline that must be true at run-time. It is shown as a rectangle with semi-circular ends.

A continuation has the same notation as a state invariant, but is used in combined fragments and can stretch across more than one lifeline.

 

2. Simple description

 

 

Click to see full-sized image

The Reservation window sends a makeReservation() message to aHotelChain. TheHotelChain then sends a makeReservation() message to aHotel. If the Hotel has available rooms, then it makes aReservation and aConfirmation.

Each vertical dotted line is a lifeline, representing the time that an object exists. Each arrow is a message call. An arrow goes from the sender to the top of theactivation bar of the message on the receiver's lifeline. The activation bar represents the duration of execution of the message.

In our diagram, the Hotel issues a self call to determine if a room is available. If so, then theHotel creates aReservation and a Confirmation. The asterisk on the self call meansiteration (to make sure there is available room for each day of the stay in the hotel). The expression in square brackets, [ ], is acondition.

The diagram has a clarifying note, which is text inside a dog-eared rectangle. Notes can be put into any kind of UML diagram.

 

FROM:

http://edn.embarcadero.com/article/31863#sequence-diagrams

http://www.sparxsystems.com/resources/uml2_tutorial/uml2_sequencediagram.html

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: UML序列图是一种用于描述系统中对象之间交互的图形化表示方法。它展示了对象之间的消息传递顺序,以及这些消息的时序关系。序列图通常用于描述系统中的业务流程或者交互式应用程序的交互过程。在序列图中,对象被表示为矩形框,消息则用箭头表示。序列图可以帮助开发人员更好地理解系统中的交互过程,从而更好地设计和实现系统。 ### 回答2: UML序列图是一种视觉化的表示法,用于描述系统中对象之间的交互关系。该图通常用于描述在软件系统中的对象之间发生的交互过程和信息流动。序列图可以在开发实时系统,异步通信或复杂的多线程程序的过程中有所帮助。 序列图由多个对象和它们之间的消息组成。每个对象可以在系统中代表一个实际的对象,例如一个业务逻辑单元或实体。序列图中的消息可以分为两种类型:同步消息和异步消息。同步消息是一种阻塞调用,表示对象A在发送消息后必须等待对象B响应后才能继续执行。异步消息是一种非阻塞调用,表示对象A向对象B发送了消息,但是不需要等待响应即可继续执行。 序列图还可以指定时间、条件和循环。时间可以是绝对或相对时间。条件允许开发人员指定必要的判断、分支和流程控制。循环指定可重复执行的某个操作,如迭代器模式。 序列图常见的应用场景包括设计和实现系统框架、测试和验证代码、产品文档编写以及向开发团队共享设计概念。使用序列图可以有助于描绘问题和设计方案,为开发人员和其他团队成员提供一个直观、易于理解的视觉化表示。这种描述交互的方法有助于开发更好的软件,并可以避免开发过程中的困难和错误。 ### 回答3: UML序列图是一种UML图示工具,用于描述软件系统中对象之间交互的序列。序列图通常用于可视化在特定情况下对象之间发生的交互,这里所说的情况一般指用例场景。 序列图提供一种在时间轴上描述系统交互的方式。在序列图中,系统交互以消息的形式表示。图中的每个对象都呈现为一个矩形框,代表对象的生命周期。生命周期包括对象创建、修改和销毁。在序列图中,执行模式以时间轴为基础,时间从上到下流动。 在序列图中,消息可以是同步的或异步的。同步消息表示在返回响应之前,发送方必须等待接收方的响应。异步消息发送方在发送消息后继续执行,而不必等待响应或结果。这种区分对于描述并发系统是非常重要的。也可以表示有条件的交互,以及还包括循环和分支等建模。 序列图非常有用,它可以帮助开发人员和项目经理更好地理解系统之间的交互,并帮助他们确定软件系统的执行路径。通过序列图,软件开发人员可以更好地理解系统的操作,并且可以检测和解决可能导致系统故障的问题。另外,序列图对于模拟系统交互和测试系统的行为也非常有用。因此,UML序列图是软件开发中不可或缺的一部分。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值