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

Chapter 7: Attributes and Operations

To show attribute and operation stereotypes for a class:

1.

Select the desired class on a diagram.

2.

Right−click on the class to display the shortcut menu.

3.

Select Options → Show Compartment Stereotypes.

To change the default stereotype display option:

1.

Select Tools → Options.

2.

Select the Diagram tab.

3.

Use the Show Stereotypes check box to set the default option.

Note When you change the default, only new diagrams will be affected. Existing diagrams will not be changed.

Mapping Operations to Messages

As we discussed above, each message on a Sequence or Collaboration diagram will be mapped to an operation. If your Sequence diagram looks like this:

292

Chapter 7: Attributes and Operations

the operation Operation1 will be placed inside Class B. When you first create your Sequence and Collaboration diagrams, you may use message names that are English phrases rather than operation names, as shown in Figure 7.16.

Figure 7.16: Sequence diagram without operation mapping

However, as you are identifying operations, you'll want to map each message to the appropriate operation. The Sequence diagram above will be changed to look like Figure 7.17.

Figure 7.17: Sequence diagram with operation mapping

293

Chapter 7: Attributes and Operations

Mapping an Operation to a Message on an Interaction Diagram

As you identify operations, go through each message on your Sequence and Collaboration diagrams. Before you generate code, be sure that each message has been mapped to the appropriate operation. Figures 7.16 and 7.17 show a Sequence diagram without and with operation mapping, respectively.

Note Operations can be mapped to messages only if the Interaction Diagram object has been mapped to a class.

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, as shown in Figure 7.18.

Figure 7.18: Mapping a message to an existing operation

4.

Select the operation from the list.

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.

294