UML Weekend Crash Course™ - To Parent Directory

UML Weekend Crash Course™ - To Parent Directory UML Weekend Crash Course™ - To Parent Directory

crnarupa.singidunum.ac.rs
from crnarupa.singidunum.ac.rs More from this publisher
01.01.2015 Views

Session 17—Applying the Sequence Diagram to the Case Study 181 Begin by identifying all the participating objects. Each object is placed at the top of the diagram, as in Figure 17-2. The order doesn’t really matter. However, when the diagram is finished, it sometimes helps to move them around to improve the readability of the messages on the diagram. This Use Case includes the Order Fulfillment Clerk, the System itself, the Orders database, two Orders (the primary and the backorder), and the Inventory. :OrderFulfillment Clerk :System :OrdersDB 12345678:Order 23456789:Order :Inventory Figure 17-2 Sequence diagram with objects and timelines The first Sequence diagram models Scenario 1. The first, or primary, scenario should be the successful path. The success path is almost always the most comprehensive. The other scenarios are then just deviations from the main scenario. Each step of the flowchart becomes a message and/or a return on the Sequence diagram (depending on how the step is described). The first step is “Get Order #.” On the Sequence diagram (Figure 17-3) this appears as a procedure call (step 1) and a response (step 2). Note the format of the procedure call (message): Sequence number (optional) A colon Condition (optional) Operation signature, which is made up of: Visibility, (+ means public, - private, # protected) Operation name (getOrderNbr) Arguments () – no arguments for this call A colon Return data type (int – meaning integer value). :OrderFulfillment Clerk :System :OrdersDB 12345678:Order 23456789:Order :Inventory 1: getOrderNbr():int 2: return 12345678 Figure 17-3 Add steps 1 and 2; get the order number

182 Saturday Evening The next step is “getOrder” from the database. In the flowchart, I stated that this was a call to the Find Order Use Case. In order to keep the focus on the Sequence diagram construction, I model it here as a procedure call with a response. In Figure 17-4, steps 3 and 4 show the call and response. :OrderFulfillment Clerk :System :OrdersDB 12345678:Order 23456789:Order :Inventory 1: getOrderNbr():int 2: return12345678 3: getOrder(ordernbr:int):Order 4: return Order 12345678 Figure 17-4 Add steps 3 and 4; get the Order using the order number The return is simply the data (the Order) being sent back as a result of performing the operation. Remember that the Sequence diagram is modeling a test case, so the return should be a value. Sometimes you’ll model a rule, in which case you would show the return data type rather than a specific value. The next step is “display Order.” Because this message does not require a response, Figure 17-5 shows the use of an asynchronous communication using a line-style arrow. There is no corresponding return arrow. :OrderFulfillment Clerk :System :OrdersDB 12345678:Order 23456789:Order :Inventory 1: getOrderNbr():int 2: return 12345678 3: getOrder(ordernbr:int):Order 4: return Order 12345678 5: displayOrder(Order):void Figure 17-5 Add an asynchronous message. The rest of the steps are modeled in Figure 17-6. After the Order is displayed in step 5, the system asks the user for the first item to look up (step 6, getItem():int). The system is expecting to get an integer representing the number of the item on the Order to look up. It gets the reply “item #1” in step 7. The system uses the item number in step 8 to ask the Order for the corresponding product serial number. The Order returns the product serial number in step 9.

Session 17—Applying the Sequence Diagram to the Case Study 181<br />

Begin by identifying all the participating objects. Each object is placed at the top of the<br />

diagram, as in Figure 17-2. The order doesn’t really matter. However, when the diagram is<br />

finished, it sometimes helps to move them around to improve the readability of the messages<br />

on the diagram. This Use Case includes the Order Fulfillment Clerk, the System itself, the<br />

Orders database, two Orders (the primary and the backorder), and the Inventory.<br />

:OrderFulfillment Clerk :System :OrdersDB 12345678:Order 23456789:Order :Inventory<br />

Figure 17-2 Sequence diagram with objects and timelines<br />

The first Sequence diagram models Scenario 1. The first, or primary, scenario should be<br />

the successful path. The success path is almost always the most comprehensive. The other<br />

scenarios are then just deviations from the main scenario.<br />

Each step of the flowchart becomes a message and/or a return on the Sequence diagram<br />

(depending on how the step is described). The first step is “Get Order #.” On the Sequence<br />

diagram (Figure 17-3) this appears as a procedure call (step 1) and a response (step 2).<br />

Note the format of the procedure call (message):<br />

Sequence number (optional)<br />

A colon<br />

Condition (optional)<br />

Operation signature, which is made up of:<br />

Visibility, (+ means public, - private, # protected)<br />

Operation name (getOrderNbr)<br />

Arguments () – no arguments for this call<br />

A colon<br />

Return data type (int – meaning integer value).<br />

:OrderFulfillment Clerk :System :OrdersDB 12345678:Order 23456789:Order :Inventory<br />

1: getOrderNbr():int<br />

2: return 12345678<br />

Figure 17-3<br />

Add steps 1 and 2; get the order number

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!