UML series learning-sequence diagram

Source: Internet
Author: User
A sequence diagram describes the interaction modes between objects in chronological order. It uses the "lifeline" of objects and the messages passed between them to show how objects participate in interaction.

A sequence diagram is a model used to describe how object groups collaborate in certain behavior aspects over time. A sequence diagram captures the behavior of a single use case and displays the objects in the time frame of a specific use case and the messages transmitted between these objects. The sequence diagram does not show the relationship between objects.

A sequence diagram is a time series interaction diagram that emphasizes messages. It consists of actor, object, message, lifeline, and focus of control). In UML, an object is represented as a rectangle, where the object name is underlined; messages are represented by a marked arrow in a sequence diagram; and lifeline is represented by a dotted line. The control focus is represented by a thin rectangle.

A sequence diagram represents an interaction as a two-dimensional diagram with a vertical timeline and time extending down along a vertical line. The horizontal axis represents the class meta-roles of independent objects in the collaboration. The activities of the class meta-role are represented by the lifeline. When an object exists, the lifeline is represented by a vertical dotted line. When the object is activated, the lifeline is a dual-track line.

A sequence diagram describes in detail the interaction between a business role and a business principal, and how to access a business entity when executing a business case. The sequence diagram briefly describes the work of involved business roles, describes how to operate business entities from the activation perspective, and how they implement communication by sending messages.

The sequence diagram of some personal registry business use cases.

You can also use a collaboration diagram to describe the information in a sequence diagram (see Guide: collaboration diagrams in the Business Object Model ). 1987-2001 Rational Software Corporation. Copyright.

Usage of a sequence chart

· When multiple short methods exist between different classes, describe the overall sequence of the Control Flow
· Display concurrent processes and Activation
· Time series that are hard to describe in the Collaboration Diagram
· Display general forms unrelated to objects involving Class interactions

How to Create a sequence diagram 
 

This section contains the following content:

·Generate a sequence diagram ·Complete generated Sequence Diagram Generation Sequence Diagram 1. If necessary, start IDE. 2. In the project window, expand" Umltutorialproject">" Model"Node. 3. Right-click" Collaborationdigoal"Node, and then select" create graph with selected elements "from the context menu ".

The "New wizard" window is displayed, and the "Create New Graph" page is displayed.

  You can select one of the two types of available interaction diagrams from the context menu: Collaboration diagram and sequence diagram. These graphs emphasize the interaction between objects.
4. In the "Graph type" list, select "sequence diagram ". 5. In the "Graph name" field, Type Sequencedi.pdf. 6. Retain the default settings in the "namespace" field and click "OK ".
IDE will perform the following operations: CollaborationdigoalCreate under Node Sequencedi.pdfNode o displays a new graph in the Graph Editor. This graph is composed of a lifeline element and a message from the collaboration graph. Open "modeling component panel ", the icons used to create a sequence chart are displayed.

This graph should be similar to the following graph. The objects in the generated sequence diagram transaction are drawn as point-point vertical bars, and their names are displayed on the top. Because the sequence of lifeline elements cannot be defined in advance when creating a sequence chart, you need to re-sort these elements at this time. 1. Select the lifeline marked as user and move it to the left of the graph. 2. Re-sort the remaining lifeline elements so that they are evenly distributed in the Graph Editor. Place the lifeline from left to right in the following order: o User o ATM o consortium O branch

Now, this graph should be similar to the following graph.

 

Add a self-called Message Element
 

The self-called message graph element indicates the message used to call an object. The internal operation shown in this figure is to verify the existing cash in the ATM object. 1. You may need to extend the lifeline element to facilitate the placement of message elements. To extend the lifeline, follow these steps: A. Select the user lifeline element. B. Click the blue box in the center at the bottom and drag the box down to extend the lifeline. C. Repeat steps A and B to extend other lifeline until the figure is similar to the following figure. 2. Select the "self-called message" icon from the "Basic" category of "modeling component panel. 3. Click the lower half of the extended ATM lifeline element.

IDE will place a self-called message element in this life line. 4. Right-click to deselect the "self-called message" icon. 5. In the self-called message element, click the message Arrow below.

The message attributes are displayed in the Properties window. 6. In the "name" Field of the "properties" window, TypeValidatecashonhandoperationAnd press Enter. 7. Right-click the message arrow in the Self-called Message Element and select "operation" from the context menu ". Indicates the position where the cursor is placed. Pay attention to the double vertical lines above the top arrow.

8. Select "from the operation list"Public Boolean getisoperating".

You can see that the upper part of the message is marked, as shown in.


 

Use the call Message Element
 

Because ValidatecashonhandAn operation is a part of an ATM class. Therefore, you need to place a message stream on the life line to call this operation. 1. Select the "synchronize message" icon from the "Basic" category of "modeling component panel. 2. Click the user lifeline element under the existing Blue Bar. 3. Click the ATM lifeline element again on the right of the first click.

A message and a returned message are displayed in the figure.

  If you do not want the returned message to appear on the graph, right-click the blank area of the Graph Editor. Deselect "show all returned messages" from the context menu ".
4. 5. Right-click the message you just created and choose "operation"> "add operation" from the context menu ". Type ValidatecashonhandAnd press Enter.

IDE will mark the message on the graph and add the message as an operation to the ATM class of the class graph. In the "project" window, expand the ATM node and confirm that the operation list is similar to the following figure.


Use auto-extended message options
 

To facilitate the smooth design process, IDE has an option to automatically expand messages. If Automatic scaling is set to the selected status, the space occupied by new messages is expanded to the Message width when new messages are placed on the graph. 1. To set the auto scaling option, right-click the trail between the user and the ATM element name.

Open the context menu. 2. Select "Set width to message width ".

An indicator bar appears in the trace between two element names, as shown in.

3. Repeat the preceding steps to set the message width options between the ATM and consortium elements and between the consortium and branch elements. Back to Top

Use to create a message symbol  
 

The "create message" symbol can be used to create a lifeline element or instance. 1. Select the "Create message" icon from the "Basic" category of "modeling component panel. 2. Click the lower half of the branch lifeline.

  Be sure to click online. Otherwise, the link cannot be correctly drawn.
3. Draw the link until the right side of the branch lifeline, and click again.

In this way, a message and a lifeline will be placed on the graph ,.
5. Right-click the icon to unselect it. 6. select a new lifeline.

The "properties" window displays the attributes of this lifeline element. 7. Click the downward arrow on the row marked as "representing class elements" in the "properties" window.

A drop-down list is displayed. 8. Select "cashierstation" from the drop-down list and press Enter. 9. Click Graph Editor to view the lifeline element with tags.

  You can relax the new line element until you see its complete name cashierstation.
10. The image should be similar to the following figure.

Add asynchronous Link  
 

An asynchronous message element indicates that messages of the called object are not blocked. Such messages can create new objects, create new threads, and communicate with existing threads. 1. Select the "Asynchronous Message" icon from the "Basic" category of "modeling component panel. 2. Click the branch lifeline element, and then click the cashierstation lifeline element to draw a link between the Branch and cashierstation lifeline. 3. Right-click the icon to unselect it. 4. Right-click the new link and select "operation"> "from the context menu" Public int getstationid".

This operation adds an operation to the message, as shown in.

Use a combination of fragment Elements
A combination fragment can directly represent a logical component in a sequence diagram, such as a standby option, option, exception, Parallel Merge, loop, reverse lookup, critical area, and assertion. A combination fragment provides a way to define special conditions and sub-processes for any part of any lifeline by specifying conditions or application regions of sub-processes. 1. Select the "combined fragment" icon from the "control" category of "modeling panel. 2. You need to draw a combination of fragment elements to encapsulate messages. Public void validatecashonhand, Click the outside of the blue dotted line rectangle that represents the message, and then stretch the rectangle to enclose the message.

Do not select any lifeline element when you click. Shows your combination fragments.

3. Right-click the icon to unselect it. 4. Right-click"Assert"Tag, and then select" Interactive operator ">" loop ".

  The loop interaction operator specifies a combination of fragments to represent a loop. The result of the trigger expression is calculated every time a loop is repeated. The trigger expression can include a specific number of iterations.
5. Right-click and mark" Loop", And then select" interaction operations ">" Edit interaction constraints "from the context menu ".

IDE displays an expression box in the target combination fragment element. 6. Double-click the word expression to make the expression editable, as shown in.

7. TypeX <10And press Enter. 8. Click Graph Editor.

This expression will be accepted and displayed in the box. This graph should be similar to the following graph.

Save Graph
You can save a sequence chart. 1. In the Graph Editor, right-click" Sequencedi.pdf"Tag. 2. Select "Save document" from the context menu ".

This will close the menu and save the sequence diagram.

  When you exit the IDE, the system prompts you whether to save the graph.
Back to Top

Summary  
In this tutorial, you learned how to use existing class diagrams and collaborative diagrams to create sequence diagrams. I learned how to perform the following tasks: · generate a sequence diagram from an existing collaboration diagram · use the icon in the "modeling component panel" to add a message to a diagram · add a link to a diagram · Add a composite fragment element · Save a diagram

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.