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

Chapter 7: Attributes and Operations

Figure 7.14: Operation semantics

To specify the operation semantics:

1.

Open the operation specification window.

2.

Select the Semantics tab.

3.

Enter the semantics in the Semantics field.

Displaying Attributes and Operations on Class Diagrams

UML is very flexible; it allows for either all details to be shown on a Class diagram or only those details you'd like to see. In Rose, you can customize your Class diagrams to do the following:

Show all attributes and operations

Hide the attributes

285

Chapter 7: Attributes and Operations

Hide the operations

Show selected attributes and operations

Show operation signatures or operation names only

Show or hide attribute and operation visibility

Show or hide operation and attribute stereotypes

In the following sections, we'll take a look at each of these options. In a typical project, you'll have many Class diagrams. Some will focus on the relationships, and will show little attribute and operation detail. Others may focus on the classes, and may not show attributes and operations at all. Still others may focus on the attributes and operations, showing all of the detailed information. In Rose, you can place a class on as many Class diagrams as you'd like. You can then use the following options to show or hide the attribute and operation details.

You can set the defaults for each of these options using the Tools → Options window. The specific instructions for setting the defaults are listed in the following sections.

Showing Attributes

For a given class on a Class diagram, you can:

Show all attributes

Hide all attributes

Show selected attributes

Suppress attributes

Suppressing the attributes will not only hide the attributes on the diagram, but will remove the line indicating where the attributes would be located in the class. To illustrate the difference between hiding and suppressing attributes, let's look at an example. Here we have Employee class with hidden attributes:

286

Chapter 7: Attributes and Operations

Here, we have the same class, but the attributes have been suppressed:

There are two ways to change the attribute display options. You can visit each class individually and set the appropriate options. Or, you can change the default attribute display options before you create the Class diagram. When you change the defaults, only new diagrams will be affected.

To show all attributes 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 All Attributes.

To show selected attributes 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 → Select Compartment Item.

4.

Select the desired attributes in the Edit Compartment window.

OR

1.

Select the desired class on a diagram.

2.

Select Edit → Compartment.

3.

Select the desired attributes in the Edit Compartment window, as shown in Figure 7.15.

287

Chapter 7: Attributes and Operations

Figure 7.15: Selecting attributes in the Edit Compartment window

To suppress all attributes for a class on a diagram:

1.

Select the desired class.

2.

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

3.

Select Options → Suppress Attributes.

To change the default option for showing attributes:

1.

Select Tools → Options.

2.

Select the Diagram tab.

3.

Use the Suppress Attributes and Show All Attributes check boxes to set the default options.

Note When the default is changed, only new diagrams will be affected. Existing Class diagrams will not be changed.

Showing Operations

As with attributes, you have several choices for displaying operations:

Show all operations

Show selected operations

 

 

Hide all operations

 

 

Suppress operations

 

In addition, you have the following options:

 

288

Chapter 7: Attributes and Operations

Display operation name only, which will display the operation name on the Class diagram, but hide the operation's arguments and return type.

Display full operation signature, which will show not only the operation's name, but all of the parameters, parameter data types, and the operation return type.

To show all operations 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 All Operations.

To show selected operations 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 → Select Compartment Items.

4.

Select the desired operations in the Edit Compartment window.

OR

1.

Select the desired class on a diagram.

2.

Select Edit → Compartment.

3.

Select the desired operations in the Edit Compartment window.

To suppress all operations for a class:

1.

Select the desired class on a diagram.

2.

Right−click on the class to display the shortcut.

3.

289