Tuesday, December 26, 2017

Create a UML sequence diagram

Create a UML sequence diagram

Sequence diagram displaying how objects interact through time

The vertical dimension in a sequence diagram represents time, with time proceeding down the page. The horizontal dimension represents different actors or objects.

Callout 1 Objects are represented as object lifelines, that is, in terms of their existence at a particular time. Adjust line length to indicate an object's creation or destruction.

Callout 2 Arrows represent messages between objects. An object can also send a message to itself.

Callout 3 Add an activation (also called a focus of control) to a lifeline to indicate the time period during which an object is performing an action.

Callout 4 A return message is shown as a dashed line.

  1. On the File menu, point to New, point to Software, and then click UML Model Diagram.

  2. In the tree view, right-click the package or subsystem in which you want to include the sequence diagram, then point to New, and then click Sequence Diagram.

    A blank page appears, and the UML Sequence stencil becomes the top-most stencil. The workspace displays 'Sequence' as a watermark. An icon representing the diagram is added to the tree view.

    Note: If the tree view is not visible, on the UML menu, point to View, and then click Model Explorer.

  3. For each object involved in the interaction the sequence diagram represents, drag an Object Lifeline shape onto the drawing page. Adjust the lengths of the lifelines to correspond to the lengths of the objects' lives in the interaction, and add destruction markers to lifelines for objects that are destroyed.

    Object Lifeline shape

    Indicate that an object in a sequence diagram is destroyed

    1. In a sequence diagram, drag an Object Lifeline shape onto the drawing page to represent an object that is destroyed during the interaction the sequence diagram represents.

    2. Right-click the Object Lifeline shape, click Shape Display Options, and then select Destruction marker.

      Note: To apply this change only to the selected shape, clear the option Apply to the same selected UML shapes in the current drawing window page in the UML Shape Display Options dialog box.

      A black X appears at the end of the object's lifeline.

  4. Double-click an Object Lifeline shape. In the UML Classifier Role Properties dialog box, click ClassifierRole. Do one of the following:

    1. Under Classifier, choose the classifier the object represents, and then click OK.

    2. Click New to create a new classifier in the system.

      The appearance of the object icon may change to reflect the classifier you chose.

  5. To indicate when an object is performing an action, drag an Activation shape onto the object's lifeline. Glue the endpoints of the Activation shape to connection points on the Object Lifeline shape. Adjust the length of the activation rectangle to correspond to the object's period of activity.

    Activation shape

    Indicate transition times on a sequence diagram

    1. In the tree view, double-click the icon representing the sequence diagram to which you want to add transition times.

      The drawing page with the sequence diagram appears.

    2. On the toolbar, select the Text tool Text tool button .

    3. On the drawing page, click where you want to add the name of the message instance, which represents the time the message is sent, and then type the name.

      Usually, the name appears in the left margin of the diagram aligned with the message to which it applies. The name can be a simple letter, such as a or b.

    4. On the toolbar, select the Pointer tool Button image .

    5. Drag a Constraint shape onto the drawing page near the message name. Double-click the shape, and under Body, type any constraint information relevant to the message time (for example, b - a < 1 sec). Click OK.

      Tip: If the delivery of a message is not instantaneous, slant the message line and name the time the message is received with the same letter as the time the message is sent, but add a prime (for example, a for the time sent and a' for the time received).

      Information about messages can be added to the left margin

      A sequence diagram with named times for when messages are sent and received.

    Show conditionality on a sequence diagram object

    1. In a sequence diagram, drag a Lifeline shape onto the drawing page near the object lifeline on which you want to show conditionality.

    2. Glue the endpoints of the Lifeline shape to connection points Connection point image - blue X on the Object Lifeline shape. To extend the conditional lifeline, drag a control handle Control handle image - yellow diamond on the Lifeline shape.

    3. Double-click the Lifeline shape to open its UML Properties dialog box where you can add a name and other property values to the lifeline.

      Tip: You can also glue the endpoints of a Lifeline shape to connection points on an Activation shape associated with an object lifeline.

  6. Use Message shapes to indicate communication between the objects.

    Message shapes

    Indicate a message between objects on a sequence diagram

    1. In a sequence diagram, drag a Message shape onto the drawing page.

      The message shape you choose depends upon the kind of message you want to send (regular, asynchronous, procedure call, or return).

    2. Glue the message endpoint without the arrowhead to a connection point Connection point image - blue X on the lifeline of the object sending the message.

    3. Glue the message endpoint with the arrowhead to a connection point on the lifeline of the object receiving the message.

    4. Double-click the message, and then type or choose the message name, stereotype, sequence expression, and flow kind.

    5. For a flat message or procedure call, choose the operation you want the message to generate. If the operation doesn't exist, click New to create it.

      For an asynchronous message, choose the signal you want the message to generate. If no reception for the signal exists on the classifier that the object lifeline receiving the message is based on, click New to create the reception.

      Tip: To indicate a message from an object to itself, glue the two endpoints on an arc-shaped Message shape to two connection points on the same object lifeline.

  7. Double-click any shape to open its UML Properties dialog box, where you can add a name and other property values.

  8. Save the diagram.

No comments:

Post a Comment