# [NEW] Sequence Diagram Tutorial – Complete Guide with Examples | sequence diagram – Pickpeup

sequence diagram: นี่คือโพสต์ที่เกี่ยวข้องกับหัวข้อนี้

This sequence diagram tutorial is to help you understand sequence diagrams better; to explain everything you need to know, from how to draw a sequence diagram to the common mistakes you should avoid when drawing one.

There are 3 types of Interaction diagrams; Sequence diagrams, communication diagrams, and timing diagrams. These diagrams are used to illustrate interactions between parts within a system. Among the three, sequence diagrams are preferred by both developers and readers alike for their simplicity.

In this sequence diagram tutorial you will learn about;

เนื้อหา

### What is a Sequence Diagram?

Sequence diagrams, commonly used by developers, model the interactions between objects in a single use case. They illustrate how the different parts of a system interact with each other to carry out a function, and the order in which the interactions occur when a particular use case is executed.

In simpler words, a sequence diagram shows different parts of a system work in a ‘sequence’ to get something done.

### Sequence Diagram Notations

A sequence diagram is structured in such a way that it represents a timeline which begins at the top and descends gradually to mark the sequence of interactions. Each object has a column and the messages exchanged between them are represented by arrows.

A Quick Overview of the Various Parts of a Sequence Diagram

Lifeline Notation

A sequence diagram is made up of several of these lifeline notations that should be arranged horizontally across the top of the diagram. No two lifeline notations should overlap each other. They represent the different objects or parts that interact with each other in the system during the sequence.

A lifeline notation with an actor element symbol is used when the particular sequence diagram is owned by a use case.

A lifeline with an entity element represents system data. For example, in a customer service application, the Customer entity would manage all data related to a customer.

A lifeline with a boundary element indicates a system boundary/ software element in a system; for example, user interface screens, database gateways or menus that users interact with, are boundaries.

And a lifeline with a control element indicates a controlling entity or manager. It organizes and schedules the interactions between the boundaries and entities and serves as the mediator between them.

Activation Bars

Activation bar is the box placed on the lifeline.  It is used to indicate that an object is active (or instantiated) during an interaction between two objects. The length of the rectangle indicates the duration of the objects staying active.

In a sequence diagram, an interaction between two objects occurs when one object sends a message to another. The use of the activation bar on the lifelines of the Message Caller (the object that sends the message) and the Message Receiver (the object that receives the message) indicates that both are active/is instantiated during the exchange of the message.

Message Arrows

An arrow from the Message Caller to the Message Receiver specifies a message in a sequence diagram.   A message can flow in any direction; from left to right, right to left or back to the Message Caller itself. While you can describe the message being sent from one object to the other on the arrow, with different arrowheads you can indicate the type of message being sent or received.

The message arrow comes with a description, which is known as a message signature, on it. The format for this message signature is below. All parts except the message_name are optional.

As shown in the activation bars example, a synchronous message is used when the sender waits for the receiver to process the message and return before carrying on with another message.  The arrowhead used to indicate this type of message is a solid one, like the one below.

READ  [Update] 해리 왕자 부부, '어머니의날' 맞아 새 로열베이비 사진 공개 | 서섹스 - Pickpeup

An asynchronous message is used when the message caller does not wait for the receiver to process the message and return before sending other messages to other objects within the system. The arrowhead used to show this type of message is a line arrow like shown in the example below.

A return message is used to indicate that the message receiver is done processing the message and is returning control over to the message caller. Return messages are optional notation pieces, for an activation bar that is triggered by a synchronous message always implies a return message.

Tip: You can avoid cluttering up your diagrams by minimizing the use of return messages since the return value can be specified in the initial message arrow itself.

Objects do not necessarily live for the entire duration of the sequence of events. Objects or participants can be created according to the message that is being sent.

The dropped participant box notation can be used when you need to show that the particular participant did not exist until the create call was sent.  If the created participant does something immediately after its creation, you should add an activation box right below the participant box.

• Participant destruction message

Likewise, participants when no longer needed can also be deleted from a sequence diagram. This is done by adding an ‘X’ at the end of the lifeline of the said participant.

When an object sends a message to itself, it is called a reflexive message. It is indicated with a message arrow that starts and ends at the same lifeline as shown in the example below.

Comment

UML diagrams generally permit the annotation of comments in all UML diagram types. The comment object is a rectangle with a folded-over corner as shown below. The comment can be linked to the related object with a dashed line.

Note:  View Sequence Diagram Best Practices to learn about sequence fragments.

### Sequence Diagram Best Practices

• Manage complex interactions with sequence fragments

A sequence fragment is represented as a box that frames a section of interactions between objects (as shown in the examples below) in a sequence diagram.

It is used to show complex interactions such as alternative flows and loops in a more structured way. On the top left corner of the fragment sits an operator. This – the fragment operator – specifies what sort of a fragment it is.

The alternative combination fragment is used when a choice needs to be made between two or more message sequences. It models the “if then else” logic.

The alternative fragment is represented by a large rectangle or a frame; it is specified by mentioning ‘alt’ inside the frame’s name box (a.k.a. fragment operator).

To show two or more alternatives, the larger rectangle is then divided into what is called interaction operands using a dashed line, as shown in the sequence diagram example above. Each operand has a guard to test against and it is placed at the top left corner of the operand.

The option combination fragment is used to indicate a sequence that will only occur under a certain condition, otherwise, the sequence won’t occur. It models the “if then” statement.

Similar to the alternative fragment, the option fragment is also represented with a rectangular frame where ‘opt’ is placed inside the name box.

Unlike the alternative fragment, an option fragment is not divided into two or more operands. Option’s guard is placed at the top left corner.

Loop fragment is used to represent a repetitive sequence. Place the words ‘loop’ in the name box and the guard condition near the top left corner of the frame.

In addition to the Boolean test, the guard in a loop fragment can have two other special conditions tested against. These are minimum iterations (written as and maximum iterations (written as maxint = [the number]).

READ  [Update] 최고의 몸매를 소유한 AV배우 100인 (스압) | 아리사 후지 - Pickpeup

If it is a minimum iterations guard, the loop must execute not less than the number mentioned, and if it is a maximum iterations guard, the loop mustn’t execute more than the number indicated.

(Find an example of a loop fragment below in the sequence diagram templates and example section)

You can use the ref fragment to manage the size of large sequence diagrams. It allows you to reuse part of one sequence diagram in another, or in other words, you can reference part of a diagram in another diagram using the ref fragment.

To specify the reference fragment, you have to mention ‘ref’ in the name box of the frame and the name of the sequence diagram that is being referred to inside the frame.

• Draw smaller sequence diagrams that capture the essence of the use case

Instead of cluttering your sequence diagram with several objects and groups of messages that will confuse the reader, draw a few smaller sequence diagrams that aptly explain what your system does.  Make sure that the diagram fits on a single page and leaves space for explanatory notes too.

Also instead of drawing dozens of sequence diagrams, find out what is common among the scenarios and focus on that. And if the code is expressive and can stand on its own, there’s no need to draw a sequence diagram in the first place.

### How to Draw a Sequence Diagram

A sequence diagram represents the scenario or flow of events in one single use case. The message flow of the sequence diagram is based on the narrative of the particular use case.

Then, before you start drawing the sequence diagram or decide what interactions should be included in it, you need to draw the use case diagram and ready a comprehensive description of what the particular use case does.

From the above use case diagram example of ‘Create New Online Library Account’, we will focus on the use case named ‘Create New User Account’ to draw our sequence diagram example.

Before drawing the sequence diagram, it’s necessary to identify the objects or actors that would be involved in creating a new user account. These would be;

• Librarian
• Online Library Management system
• User credentials database
• Email system

Once you identify the objects, it is then important to write a detailed description on what the use case does. From this description, you can easily figure out the interactions (that should go in the sequence diagram) that would occur between the objects above, once the use case is executed.

Here are the steps that occur in the use case named ‘Create New Library User Account’.

• The librarian request the system to create a new online library account
• The librarian then selects the library user account type
• The librarian enters the user’s details
• The user’s details are checked using the user Credentials Database
• The new library user account is created
• A summary of the of the new account’s details are then emailed to the user

From each of these steps, you can easily specify what messages should be exchanged between the objects in the sequence diagram. Once it’s clear, you can go ahead and start drawing the sequence diagram.

The sequence diagram below shows how the objects in the online library management system interact with each other to perform the function ‘Create New Library User Account’.

### Sequence Diagram Common Mistakes

When drawing sequence diagrams, designers tend to make these common mistakes. By avoiding these mistakes you can ensure the quality of your diagram.

• Adding too much detail. This clutters up the diagram and makes it difficult to read.
• Obsolete and out of date sequence diagrams that are irrelevant when compared to the interfaces, actual architectures etc. of the system. Don’t forget to replace them or modify them.
• Leaving no blank space between the use case text and the message arrow; this makes it difficult for anyone to read the diagram.
• Not considering the origins of message arrows carefully.
READ  [NEW] DragonBallCreative Minecraft | bboy dragon - Pickpeup

See these common mistakes explained in detail in Sequence Diagram Guide: Common Mistakes to Avoid When Drawing Sequence Diagrams.

### Sequence Diagram Examples and Templates

Following are a few sequence diagram examples and templates that are drawn using Creately. Create sequence diagrams online using Creately’s online tool. Click on the template to open it in the editor.

Online Examination System – Class Diagram (UML)

### Feedback on the Sequence Diagram Tutorial

This sequence diagram tutorial covers everything you need to know on sequence diagrams and drawing them. If you have any suggestions or questions regarding the sequence diagram tutorial, feel free to leave a comment.

### More Diagram Tutorials

Join over thousands of organizations that use Creately to brainstorm, plan, analyze, and execute their projects successfully.

Get started here

## LT3 – Activity Diagram dang nhap

นอกจากการดูบทความนี้แล้ว คุณยังสามารถดูข้อมูลที่เป็นประโยชน์อื่นๆ อีกมากมายที่เราให้ไว้ที่นี่: ดูเพิ่มเติม

## [Phân tích thiết kế] – Bài 3: Tạo Activity Diagram | HowKteam

[Phân tích thiết kế] Bài 3: Tạo Activity Diagram | HowKteam
Nếu các bạn thấy hay thì hãy đăng ký theo dõi kênh, like, share cho mọi người cùng tham gia nhé.
Muốn ủng hộ mình các bạn có thể nhấn vào quảng cáo hiện lên và load xong để mình được ít tiền duy trì nhé.
Cảm ơn mọi người.
Học thêm kiến thức hoặc tải tài liệu tại https://www.howkteam.com/
Luyện tập trắc nghiệm mỗi ngày tại https://kquiz.vn/
Bài trước:
[Phân tích thiết kế] Bài 2: Tạo lược đồ Usecase | HowKteam
Bài sau:
[Phân tích thiết kế] Bài 4: Giới thiệu về ER Diagram | HowKteam
Tập hợp khóa học lập trình cơ bản đến nâng cao.
Tham gia group để cập nhật thêm thông tin cũng như tham gia khóa học online miễn phí.
Group FB: https://goo.gl/8T2krI
Website: http://www.howkteam.com/
Danh sách phát: https://goo.gl/0LIji0
C++:
Lập trình C++: https://goo.gl/8RCMte
Bài toán kinh điển C++: https://goo.gl/7CszwZ
C:
Lập trình C: https://goo.gl/AhxyAI
Lập trình C WinForms: https://goo.gl/dPbSm4
Lập trình ASP.NET MVC: https://goo.gl/riqrzP
Java:
Lập trình Java: https://goo.gl/VoDbbs
Lập trình Android: https://goo.gl/LyV3ZX
Game:
Lập trình Unity 3D: https://goo.gl/RcBi6c
Office:
Office Word 2016: https://goo.gl/GQUk5E
Office Excel 2016: https://goo.gl/N3qdKs
Office Power Point 2016: https://goo.gl/zegyVx
Products:
Game Caro C Winforms: https://goo.gl/bMuXEC
Game Flappy Bird Unity 3D: https://goo.gl/K00l5y
Game bắn Zombies Unity 3D: https://goo.gl/HUjWlt
Game Doge Unity 3D: https://goo.gl/0pysFu
App lập lịch C Winforms: https://goo.gl/xO0iX3
App từ điển nói C Winforms: https://goo.gl/KgHNNn
App quản lý quán Cafe C Winforms: https://goo.gl/FLZDDM
App key logger C Winforms: https://goo.gl/qV93CV
Stream:
Kỹ thuật: https://goo.gl/tGtmwq
Kinh nghiệm: https://goo.gl/VsQjkc
Âm thanh:
Two Step From Hell Colors Of Love
http://fbl.me/TJB
http://www.thomasbergersen.com/

## SEQUENCE DIAGRAM | Hướng dẫn vẽ tay | Carry by Tùng T.Tr

Hướng dẫn sử dụng trước khi dùng:

⭐️ Để cập nhật những mánh giải bài độc đáo, mẹo + thông tin công nghệ mới nhất đồng thời hỏi đáp tư vấn hay truy cập trang tin: https://carry4ublog.wordpress.com/
⭐️Kênh chém gió và crack bài tập dạo: https://www.youtube.com/channel/UCtO8856yQizhLPAEn4eA
500 ANH EM HÃY VỀ CHUNG MỘT NHÀ VỚI TỤI MÌNH NHA :v