Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Mastering UML with Rational Rose 2002.pdf
Скачиваний:
137
Добавлен:
02.05.2014
Размер:
9.68 Mб
Скачать

Chapter 5: Object Interaction

To name a message:

1.

Double−click the message on the Sequence or Collaboration diagram.

2.

If you have mapped the receiving object to a class, the operations of that class will appear in the Name drop−down list box. Select an entry from the list or type in the name of the message.

OR

1.

Select the message on the Sequence or Collaboration diagram.

2.

Type the message name.

Note If you have mapped the receiving object to a class, the name of the receiving class will appear next to the name, in the Class field. This field cannot be modified. To change the receiving class, map the object to another class in the object specification window.

To add documentation to a message:

1.

Double−click the message to open the message specification window.

2.

In the Documentation area, enter comments for the message. You may, for example, want to enter a little bit of pseudocode that describes what the message will do.

OR

1.

Select the message on the Sequence or Collaboration diagram.

2.

Enter comments in the Documentation window.

Mapping a Message to an Operation

Before you generate code, each message on your Sequence and Collaboration diagrams should be mapped to an operation of a class. In this example, the message "Request Some Functionality" will be mapped to an operation of the Supplier class.

183

Chapter 5: Object Interaction

To map a message to an existing operation:

1.

Be sure the receiving object (the supplier) has been mapped to a class.

2.

Right−click the message in the Sequence or Collaboration diagram.

3.

A list of the supplier's operations will appear.

4.

Select the operation from the list, as shown in Figure 5.16.

Figure 5.16: Mapping a message to an existing operation

To remove a message's operation mapping:

1.

Double−click the message in the Sequence or Collaboration diagram.

2.

In the Name field, delete the operation name and enter the new message name.

To create a new operation for the message:

1.

Be sure the receiving object (the supplier) has been mapped to a class.

2.

Right−click the message in the Sequence or Collaboration diagram.

3.

Select <new operation>.

4.

Enter the new operation's name and details. (The options available on the operation specification window are discussed in detail in Chapter 7, "Attributes and Operations.")

5.

Click OK to close the operation specification window and add the new operation.

6.

184

Chapter 5: Object Interaction

Right−click the message.

7.

Select the new operation from the list that appears.

To ensure each message has been mapped to an operation:

1.

Select Report → Show Unresolved Messages.

2.

Rose will display a list of all messages that have not yet been mapped to operations.

Setting Message Synchronization Options

In the Detail tab of the message specification window, as shown in Figure 5.17, you can specify the concurrency of the message being sent.

Figure 5.17: Setting synchronization options

The arrows on the diagram will change if you set the concurrency to Balking, Timeout, or Asynchronous. You have seven synchronization options:

Simple This is the default value for messages. This option specifies that the message runs in a single thread of control. On the Sequence diagram, simple messages use this symbol:

185

Chapter 5: Object Interaction

Synchronous Use this option when the client sends the message and waits until the supplier has acted upon the message. On the Sequence diagram, synchronous messages will appear this way:

Balking With this option, the client sends the message to the supplier. If the supplier is not immediately ready to accept the message, the client abandons the message. On the Sequence diagram, balking messages appear like this:

Timeout Using this option, the client sends the message to the supplier and waits a specified amount of time. If the supplier isn't ready to receive the message in that time, the client abandons the message. On the Sequence diagram, timeout messages appear using this arrow:

Asynchronous With this option, the client sends the message to the supplier. The client then continues processing, without waiting to see if the message was received or not. On the Sequence diagram, asynchronous messages look like this:

186

Chapter 5: Object Interaction

Procedure Call With this option, the client sends the message to the supplier. The client then must wait until the entire nested sequence of messages is processed before continuing. On the Sequence diagram, procedure call messages look like this:

Return This option indicates the return from a procedure call. On the Sequence diagram, return messages look like this:

To set the message synchronization:

1.

Double−click the message on the Sequence or Collaboration diagram.

2.

In the message specification window, select the Detail tab.

3.

Select the desired synchronization option from the radio buttons in the window.

187