G&#x
F3;i Microsoft Visio 2 G&#x
F3;i Visio 1 Microsoft Visio Professional 2021 Visio Professional 2019 Visio Professional năm 2016 Visio Professional 2013 Visio 2007 coi th&#x
EA;m...&#x
CD;t hơn

A UML sequence diagram shows how a phối of objects interact in a process over time. It shows the messages that pass between participants & objects in the system, & the order in which they occur.

Bạn đang xem: Cách vẽ sơ đồ sequence diagram

*


To build a sequence diagram, use a UML Sequence template or starter diagram, which includes the UML Sequence stencil. Drag shapes from the stencil onto the drawing canvas khổng lồ build the diagram.

Start a sequence diagram

Start Visio. Or if you have a file mở cửa already, click File > New.

In the search box, type UML sequence.

Select the UML Sequence diagram.

In the dialog box, select the blank template or one of the three starter diagrams. (A description of each one is shown on the right when you select it.) Then select either Metric Units or US Units.

Select Create.

The diagram opens. You should see the Shapes window next lớn the diagram. If you don’t see it, go khổng lồ View > Task Panes & make sure that Shapes is selected. If you still don’t see it, click the Expand the Shapes window button on the left.

On the View tab, make sure the check box next khổng lồ Connection Points is selected. This option makes connection points appear when you start connecting shapes.

Now, drag shapes you want khổng lồ include in your diagram from the Shapes window to the page. To lớn rename text labels, double-click the labels.

Lifelines for actors và objects

Use an Actor lifeline shape for each participant, và an Object lifeline shape for each system component in your process.




Attach the beginning endpoint khổng lồ the lifeline sending the message, then drag the head endpoint to lớn the lifeline receiving the message.

Double-click the message shape khổng lồ create a text box, and type a name for the message.

Use a Message shape (a solid line) khổng lồ represent a request or the transmitting of information.

Use a Return Message shape (a dashed line) khổng lồ represent a response to lớn a prior message.

Use a Self Message to represent a recursive gọi of an operation, or one method calling another method belonging to the same object.

Use the Asynchronous Message shape to show when an kích hoạt might not happen immediately.

To change the shape of a connector message:

Right-click the connector.

At the bottom of the pop-up menu, select from the three options (Right-Angle, Straight, Curved).

Click và drag the connector to change its shape.

Fragments

If one or more interactions size a loop, or require a condition lớn be met to end the interaction, enclose those interactions in a fragment shape:

Use the Loop fragment for a basic repeating interaction.

Use the Optional fragment for steps that are only performed if a certain condition is met.

Use the Alternative fragment shape for an if-then or if-then-else process or interaction. The fragment comes with two sections, which let you show the alternative interaction. To showroom another condition, drag an Interaction operand onto the shape. 

Drag the fragment shape to lớn the interactions it relates to. Use the sizing handles on the fragment shape to ensure it encloses all of the related interactions.

Double-click in the title corner of the fragment shape to địa chỉ cửa hàng a title or short mô tả tìm kiếm of the process enclosed by the fragment. Below the title corner, click the prompt if you want to enter the conditions that would end that process.

Activation


*


Start a sequence diagram

Near the upper right corner of the page, select More templates.

In the Gallery, scroll down khổng lồ the UML Sequence row.

The first item in the row represents a blank template plus the companion stencil. The other items in the row are sample diagrams that have some shapes already drawn khổng lồ help you get started quickly.

Click any nhà cửa to see a larger preview.

When you find the diagram you want to use, click its Create button.

The new diagram, with the related stencil, opens in your browser.

Lifelines for actors and objects

Use an Actor lifeline shape for each participant, & an Object lifeline shape for each system component in your process.




Attach the beginning endpoint lớn the lifeline sending the message, then drag the head endpoint khổng lồ the lifeline receiving the message.

Double-click the message shape to create a text box, & type a name for the message.

Use a Message shape (a solid line) to represent a request or the transmitting of information.

Use a Return Message shape (a dashed line) to represent a response lớn a prior message.

Use a Self Message to lớn represent a recursive điện thoại tư vấn of an operation, or one method calling another method belonging khổng lồ the same object.

Use the Asynchronous Message shape to lớn show when an kích hoạt might not happen immediately.

To change the shape of a connector message:

Right-click the connector.

At the bottom of the pop-up menu, select from the three options (Right-Angle, Straight, Curved).

Click & drag the connector lớn change its shape.

Fragments

If one or more interactions form a loop, or require a condition lớn be met to kết thúc the interaction, enclose those interactions in a fragment shape:

Use the Loop fragment for a basic repeating interaction.

Xem thêm: Những Bài Hát Thiếu Nhi Về Bố, Những Bài Hát Thiếu Nhi Hay Nhất Về Cha

Use the Optional fragment for steps that are only performed if a certain condition is met.

Use the Alternative fragment shape for an if-then or if-then-else process or interaction. The fragment comes with two sections, which let you show the alternative interaction. To add another condition, drag an Interaction operand onto the shape. 

Drag the fragment shape to the interactions it relates to. Use the sizing handles on the fragment shape khổng lồ ensure it encloses all of the related interactions.

Double-click in the title corner of the fragment shape to showroom a title or short description of the process enclosed by the fragment. Below the title corner, click the prompt if you want to lớn enter the conditions that would kết thúc that process.

Activation


To build a sequence diagram, use the UML Model template, which includes a set of UML Sequence shapes. Drag shapes from the stencil onto the drawing canvas to build the diagram.

Start a sequence diagram

Under Template Categories, click Software and Database, and then click UML model Diagram.

In the model Explorer tree view, right-click the package in which you want to lớn include the static structure diagram, point to lớn New, & click Sequence Diagram.

A blank page appears, and the UML Sequence stencil becomes the top-most stencil. An icon representing the diagram is added to lớn the tree view.


Note: If the tree view isn"t visible, point to lớn View on the UML menu, và then click Model Explorer.


Read on for more guidance about working with sequence diagrams.

Lifelines for actors and objects

Use an Object lifeline shape for each participant and system component in your process.

An object lifeline represents the existence of an object at a particular time. If the object is created or destroyed during the time period the diagram represents, the lifeline stops or starts at the appropriate point. An object"s destruction is marked with a large X.

Use a Lifeline shape

*
to lớn show conditionality on an object lifeline.

Messages

Drag a Message shape onto the drawing page.

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

Glue the message endpoint without the arrowhead to a connection point

*
on the lifeline of the object sending the message.

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

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

For a flat message or procedure call, choose the operation you want the message lớn generate. If the operation doesn"t exist, click New khổng lồ create it.

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


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


Constraints

If one or more interactions require a condition lớn be met to kết thúc the interaction, enclose those interactions in one of the constraint shapes:

A Constraint

*
is a specification for conditions & propositions that must be maintained as true for the system to lớn be valid. Constraints are expressed as text within braces ( ) và may be written in a predefined language, such as Object Constraint Language (OCL) or in natural language.

Drag the control handle

*
at the center of the Constraint shape and glue it to lớn a connection point on another element.

A 2-element Constraint

*
applies lớn two elements, such as two classes or two associations. The constraint is shown as a dashed arrow from one element khổng lồ the other with the constraint string label in braces ( ).

An OR Constraint

*
indicates that any instance of a class may participate in only one association at one time. The constraint is shown as a dashed line connecting two or more associations, which must have a class in common. The line is labeled by the constraint string, OR, in braces ( ).

Activation


Place an Activation bar shape on a lifeline lớn show when and for how long that object or participant is active in the process. Typically, there will be arrows going to & from an activation box to lớn demonstrate the flow of information.

Drag the endpoints of the Activation bar up or down to make it the length that you want.

Trong bài trước bọn họ đã mày mò về Sequence Diagram, những thành phần, bí quyết xây dựng và ứng dụng của nó. Trong bài xích này, họ sẽ bàn về cách ứng dụng sequence diagram để kiến thiết cho khối hệ thống e
Commerce mà chúng ta đã bàn ở bài 3 của phân mục này.

1. Thành lập Sequence Diagram

Bước 1: xác định các Use Case quan trọng kế

Tương từ bỏ như Activity Diagram, bọn họ cũng cần xác minh các Use Case mà họ cần sử dụng sequence Diagram để thiết kế chi tiết.

Xem xét phiên bản vẽ Use Case Diagram chúng ta đã vẽ ở bài 3, chúng ta có thể thấy các Use Case sau cần thiết kế:

– Xem sản phẩm theo chủng loại

– Thêm thành phầm theo đơn vị cung cấp

– Thêm giỏ hàng

– Chat

– thống trị đơn hàng

– Thanh toán

– Theo dõi đưa hàng

– Đăng nhập

Tiếp theo, chúng ta sẽ thi công cho công dụng “Xem thành phầm theo chủng loại”.

Bước 2: xem Activity Diagram cho Use Case này chúng ta xác định quá trình sau:

– người dùng chọn loại sản phẩm

– khối hệ thống sẽ lọc đem loại sản phẩm tương ứng, tiếp đến lấy giá, lấy tặng kèm và hiển thị lên màn hình.

– người tiêu dùng xem sản phẩm

Bước 3: Đối chiếu với Class Diagram chúng ta xác định các đối tượng người dùng thực hiện như sau:

Người dùng: chọn loại sản phẩm qua giao diện

Giao diện: sẽ lấy danh sách sản phẩm tương ứng từ bỏ Products

Giao diện: lấy giá của từng sản phẩm từ Class Prices với Promotion Amount tự lớp Promotions

Giao diện: tổng hợp list và hiển thị

Người dùng: coi sản phẩm

Bước 4: Vẽ sequence Diagram

– khẳng định các lớp thâm nhập vào khối hệ thống gồm: người dùng (Guest), đồ họa (GUI System), sản phẩm (Products), giá chỉ (Prices), tặng (Promotions). Trong số ấy GUI System để áp dụng chung cho giao diện, bạn cũng có thể sử dụng ví dụ trang Web nào nếu bạn đã sở hữu Mockup (thiết kế cụ thể của giao diện).

*

Hình 1. Xác minh các đối tượng người dùng tham gia vào bản vẽ

Các bước triển khai của Use Case này như sau:

Guest nhờ cất hộ yêu ước xem sản phẩm lên giao diện kèm theo chủng loại– GUI system: nhờ cất hộ yêu mong lấy danh sách các thành phầm tương ứng cùng với chủng loại cho lớp thành phầm và dìm lại danh sách.– GUI system: gởi yêu cầu lấy Giá cho từng thành phầm từ Prices– GUI system: nhờ cất hộ yêu cầu lấy tặng kèm cho từng thành phầm từ Promotions với nhận lại kết quả– GUI system: ghép lại danh sách và hiển thị lên browser cùng trả về cho Guest

Thể hiện tại lên bạn dạng vẽ như sau:

*

Hình 2. Bạn dạng vẽ Sequence Diagram cho công dụng Xem sản phẩm theo chủng loại.

 

Bước 5: chất vấn và cập nhật bạn dạng vẽ Class Diagram

Chúng ta phân biệt để triển khai được bản vẽ trên chúng ta cần bổ sung các phương thức cho những lớp như sau:

Products class: bổ sung phương thức Get
Product
Info(Product Type)
: trả về thông tin thành phầm có loại được truyền vào. Việc này các đối tượng người dùng của lớp Products hoàn toàn làm được do họ đã tất cả thuộc tính Product
Type yêu cầu họ rất có thể trả về được tin tức này.

Prices: bổ sung phương thức Get
Price(Product
ID)
: Unit
Price. Sau khi lấy được Product
ID tự Products, GUI gọi cách làm này để đưa giá của thành phầm từ lớp giá. Các đối tượng người sử dụng từ lớp Prices trả toàn thỏa mãn nhu cầu điều này.

Promotions: tương tự bổ sung phương thức Get
Promotion(Product
ID)
.

GUI System(View hàng hóa Page): bổ sung phương thức Display
Product
List(List of product)
để hiển thị list lên sản phẩm. Ngoại trừ ra, bạn cần có thêm một phương thức View
Productby
Type(Product
Type)
để miêu tả chính vận động này khi người tiêu dùng kích chọn.

Như vậy, họ thấy những phương thức trên đều triển khai được bên trên các đối tượng người sử dụng của các lớp nên xây cất của bên trên là khả thi. Bổ sung cập nhật các cách làm trên vào những Class tương ứng chúng ta có bản vẽ Class Diagram như sau:

*

Hình 3. Class Diagram sau thời điểm đã bổ sung cập nhật các phương thức mới

Ngoài ra, chúng ta cũng có thể bổ sung những lớp hình ảnh vào Class Diagram để hoàn hảo thiết kế mang đến hệ thống.

Hoàn tất sequence diagram cho toàn bộ các Use Case bọn họ sẽ xong việc thiết kế, mặt khác cũng trả tất bạn dạng vẽ Class Diagram.

2. Kết luận

Bản vẽ Squence Diagram bao gồm vai trò quan trọng đặc biệt trong việc kiến tạo hệ thống. Đồng thời giúp họ kiểm tra lại quá trình phân tích, thiết kế trước đây cũng như hoàn thành bản vẽ Class Diagram. Việc sử dụng thành thạo bạn dạng vẽ này giúp chúng ta rất những trong bài toán phân tích và thi công phần mềm.

Trong bài xích tiếp theo bọn họ sẽ bàn về Component Diagram với Deployment Diagram, những bản vẽ ở đầu cuối cho vấn đề phân tích và xây dựng hướng đối tượng sử dụng UML. Mời chúng ta đọc tiếp.