5/05/2009

Exercise 20-part3

C. Sequence Diagram.

I learn sequence diagram from sparxsystems web site.

C1. Scope of seqence diagram

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.


C2. Elements of sequence diagram
  • 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.(See figure 1). 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.(See figure 2)

Figure 1. Lifelines of sequence diagram.

Figure 2. More lifelines of sequence diagram.

  • Messages - Messages are displayed as arrows. Messages can be complete, lost or found; synchronous or asynchronous; call or signal. In the following diagram (see figure 3), 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).

Figure 3. Messages of sequence diagram.

  • 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.(See figure 4)

Figure 4. Lifeline Start and End of sequence.

  • 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. (See Figure 5).

Figure 5. Duration and Time Constraints of sequence diagram.

  • 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. (See figure 6).

Figure 6. Gate of sequence diagram.

  • 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.

Figure 7. Part Decomposition of sequence diagram.

References:

sparxsystems (2009). "UML 2 Sequence Diagram". Received 5th May, 2009 from URL - http://www.sparxsystems.com.au/resources/uml2_tutorial/uml2_sequencediagram.html


沒有留言:

發佈留言