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

Chapter 7: Attributes and Operations

Specifying the Operation Concurrency

The Concurrency field specifies how the operation will behave in the presence of multiple threads of control. There are three concurrency options:

Sequential Suggests that the operation will run properly only if there is a single thread of control. The operation must run to completion before another operation may be run.

Guarded Suggests that the operation will run properly with multiple threads of control, but only if the classes collaborate to ensure that mutual exclusion of running operations is achieved.

Synchronous Suggests that the operation will run properly with multiple threads of control. When called, the operation will run to completion in one thread. However, other operations can run in other threads at the same time. The class will take care of mutual exclusion issues, so collaboration with other classes is not required.

To specify the operation concurrency:

1.

Open the operation specification window.

2.

Select the Detail tab.

3.

Select the desired concurrency from the Concurrency box.

Specifying the Operation Preconditions

A precondition is some condition that must be true before the operation can run. You can enter any preconditions for the operation on the Preconditions tab of the operation specification window, as shown in Figure 7.12.

282

Chapter 7: Attributes and Operations

Figure 7.12: Operation preconditions

Preconditions will not affect the code that is generated for the operation. If you have an Interaction diagram that illustrates the operation preconditions, you can enter the Interaction diagram name at the bottom of the Preconditions tab.

To specify the operation preconditions:

1.

Open the operation specification window.

2.

Select the Preconditions tab.

3.

Enter the preconditions in the Preconditions field.

Specifying the Operation Postconditions

Postconditions are conditions that must always be true after the operation has finished executing. Postconditions are entered on the Postconditions tab of the operation specification window, as shown in Figure 7.13.

283

Chapter 7: Attributes and Operations

Figure 7.13: Operation postconditions

Like preconditions, the postconditions will not affect the code generated for an operation, but will appear as a comment in the generated code. If you have an Interaction diagram that includes information about the postconditions, you can enter its name at the bottom of the Postconditions tab.

To specify the operation postconditions:

1.

Open the operation specification window.

2.

Select the Postconditions tab.

3.

Enter the postconditions in the Postconditions field.

Specifying the Operation Semantics

The Semantics field of the operation specification window gives you a place to describe what the operation will do, as shown in Figure 7.14. You can use pseudocode here, or just a description, to spell out the operation logic. If you have an Interaction diagram related to the operation's semantics, you can enter it at the bottom of this tab page.

284