UML Weekend Crash Course⢠- To Parent Directory
UML Weekend Crash Course⢠- To Parent Directory UML Weekend Crash Course⢠- To Parent Directory
Session 18—Modeling the Dynamic View: The Collaboration Diagram 189 across. On a Sequence diagram there is nothing stopping you from drawing an arrow between two objects when there is no corresponding link. But doing so would model a logical interaction that cannot physically take place. You can take the opposite view that drawing a message where there is no link reveals the requirement for a new link. Just make certain that you actually update your Class diagram or, as I said before, you won’t be able to implement the message illustrated on the diagram. An advantage of the Sequence diagram is its ability to show the creation and destruction of objects. Newly created objects can be placed on the timeline at the point where they are created. The large X at the end of a timeline shows that the object is no longer available for use. Sequence diagrams also have the advantage of showing object activation. Because the Collaboration diagram does not illustrate time, it is impossible to indicate explicitly when an object is active or inactive without interpreting the types of messages being passed. Collaboration Diagram Notation The Collaboration diagram uses an Object diagram as its foundation. First, determine which objects will participate in the scenario. Draw the objects with only the name compartment, not the attributes. Then draw the links between them. Because any pair of classes can have more than one association, you need to use the Class diagram as your guide to identify the valid types of links that apply to the current sequence of messages. Figure 18-2 shows the objects and their links. You may leave the link names off of the links when there is only one type of association between the related classes. Add the names if there is more than one kind of link possible between the two objects and there is a need to clarify which relationship supports the interaction. Bill: Customer Bill’s Order : Order :Inventory Figure 18-2 Basic Collaboration diagram notation For each step of the scenario, draw the message arrow from the sending object to the receiving object. Place the message arrow parallel to the link between the sending and receiving objects. Having many messages placed on the same link is valid and, in fact, common as long as they really share the same message (arrow) type. Number the messages in the order in which they occur. The format for specifying a message is the same as on the Sequence diagram: Sequence-number Iteration : [condition] operation or return Figure 18-3 models the entire scenario for creating an order. I have added a few twists to the original in Figure 18-1 so that I can demonstrate all the notations.
190 Saturday Evening 7:addProduct(characters) 1 Bill: Customer 1:Order() 3:addItem(characters) 2 2:return Order 8:return true 5:return product available 3 Bill’s Order : Order 4 5 4:productAvailable(characters) 6:[product available] reduceInventory(product #, qty) 7 *Repeat steps 3 through 7 for each item the customer wants to add 6 :Inventory Figure 18-3 More detailed Collaboration diagram notation The following descriptions refer to the numbered items in Figure 18-3 so that you can see the notations used in context: 1. Object: This is a fully qualified object name, Bill, of the class Customer. The notation is exactly the same as on the Sequence diagram. 2. Synchronous event or procedure call: A synchronous event is a message that requires a reply, so you would expect to see a corresponding return message along the same link sometime later in the sequence. Procedure calls are simply another familiar way to describe this “ask and reply” form of interaction. 3. Return: Here is the return message for the message 1. Message 1 told the Order class to create a new Order object, Bill’s Order. When the task of creating the object is completed, it passes back a reference to the requestor, Bill. 4. Self-reference: A self-reference is simply an object talking to itself saying something like, “It’s time for me to get more coffee.” In Figure 18-3, the Order is telling itself to use the item information from step 3 to add another product to its list of items. 5. Sequence number: Because the Collaboration diagram has no way of showing the passage of time, it uses sequence numbers, like (4: ), to reveal the order of execution for the messages. There are no standards for the numbering scheme, so common sense and readability are your guides. The sequence numbers were optional on the Sequence diagram. They are required on the Collaboration diagram. 6. Anonymous object: Reference 6 shows another example of valid object notation. You do not have to name the instance if all you need to convey is that any object of this type (Inventory) would behave in this manner.
- Page 161 and 162: 138 Saturday Afternoon REVIEW The C
- Page 163 and 164: 140 Saturday Afternoon Introducing
- Page 165 and 166: 142 Saturday Afternoon Table 13-1 C
- Page 167 and 168: 144 Saturday Afternoon 28: VendorPr
- Page 169 and 170: 146 Saturday Afternoon 0..* VendorP
- Page 172 and 173: SESSION 14 Modeling the Functional
- Page 174 and 175: Session 14—Modeling the Functiona
- Page 176 and 177: Session 14—Modeling the Functiona
- Page 178: Session 14—Modeling the Functiona
- Page 181 and 182: 158 Saturday Afternoon Table 15-1 T
- Page 183 and 184: 160 Saturday Afternoon Figure 15-1
- Page 185 and 186: 162 Saturday Afternoon More product
- Page 187 and 188: 164 Saturday Afternoon start (merge
- Page 190 and 191: SESSION 16 Modeling the Dynamic Vie
- Page 192 and 193: Session 16—Modeling the Dynamic V
- Page 194 and 195: Session 16—Modeling the Dynamic V
- Page 196 and 197: Session 16—Modeling the Dynamic V
- Page 199 and 200: PART III # Saturday Afternoon Part
- Page 201 and 202: PART IV Saturday Evening Session 17
- Page 203 and 204: 180 Saturday Evening Scenario 1 Get
- Page 205 and 206: 182 Saturday Evening The next step
- Page 207 and 208: 184 Saturday Evening For Scenario 2
- Page 209 and 210: 186 Saturday Evening For subsequent
- Page 211: 188 Saturday Evening 6:addProduct(c
- Page 215 and 216: 192 Saturday Evening REVIEW The Col
- Page 217 and 218: 194 Saturday Evening Scenario 1 Get
- Page 219 and 220: 196 Saturday Evening pointing towar
- Page 221 and 222: 198 Saturday Evening :OrderFullfill
- Page 223 and 224: 200 Saturday Evening Scenario 5, in
- Page 226 and 227: SESSION 20 Modeling the Dynamic Vie
- Page 228 and 229: Session 20—Modeling the Dynamic V
- Page 230 and 231: Session 20—Modeling the Dynamic V
- Page 232 and 233: Session 20—Modeling the Dynamic V
- Page 234: Session 20—Modeling the Dynamic V
- Page 238 and 239: Part V — Sunday Morning Session 2
- Page 240 and 241: SESSION 21 Applying the Basic State
- Page 242 and 243: Session 21—Applying the Basic Sta
- Page 244 and 245: Session 21—Applying the Basic Sta
- Page 246 and 247: Session 21—Applying the Basic Sta
- Page 248: Session 21—Applying the Basic Sta
- Page 251 and 252: 228 Sunday Morning receivePmt(amt)[
- Page 253 and 254: 230 Sunday Morning Figure 22-4 repr
- Page 255 and 256: 232 Sunday Morning A substate is a
- Page 257 and 258: 234 Sunday Morning Monitor when tem
- Page 260 and 261: SESSION 23 Applying the Extended St
190<br />
Saturday Evening<br />
7:addProduct(characters)<br />
1<br />
Bill:<br />
Customer<br />
1:Order()<br />
3:addItem(characters)<br />
2<br />
2:return Order<br />
8:return true<br />
5:return product available<br />
3<br />
Bill’s Order :<br />
Order<br />
4<br />
5<br />
4:productAvailable(characters)<br />
6:[product available]<br />
reduceInventory(product #, qty)<br />
7<br />
*Repeat steps 3 through<br />
7 for each item the<br />
customer wants to add<br />
6<br />
:Inventory<br />
Figure 18-3 More detailed Collaboration diagram notation<br />
The following descriptions refer to the numbered items in Figure 18-3 so that you can see<br />
the notations used in context:<br />
1. Object: This is a fully qualified object name, Bill, of the class Customer. The notation<br />
is exactly the same as on the Sequence diagram.<br />
2. Synchronous event or procedure call: A synchronous event is a message that<br />
requires a reply, so you would expect to see a corresponding return message along<br />
the same link sometime later in the sequence. Procedure calls are simply another<br />
familiar way to describe this “ask and reply” form of interaction.<br />
3. Return: Here is the return message for the message 1. Message 1 told the Order<br />
class to create a new Order object, Bill’s Order. When the task of creating the<br />
object is completed, it passes back a reference to the requestor, Bill.<br />
4. Self-reference: A self-reference is simply an object talking to itself saying something<br />
like, “It’s time for me to get more coffee.” In Figure 18-3, the Order is telling<br />
itself to use the item information from step 3 to add another product to its list of<br />
items.<br />
5. Sequence number: Because the Collaboration diagram has no way of showing the<br />
passage of time, it uses sequence numbers, like (4: ), to reveal the order of execution<br />
for the messages. There are no standards for the numbering scheme, so common<br />
sense and readability are your guides. The sequence numbers were optional on the<br />
Sequence diagram. They are required on the Collaboration diagram.<br />
6. Anonymous object: Reference 6 shows another example of valid object notation.<br />
You do not have to name the instance if all you need to convey is that any object<br />
of this type (Inventory) would behave in this manner.