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

Chapter 4: Use Cases and Actors

Most of the tab pages in the actor specification will apply to classes, but will not apply to actors. The tab pages that include information about actors are the General tab, the Detail tab, the Relations tab, and the Files tab. Some of the options on these tabs apply only to classes. The options that are available for actors are described below.

Naming Actors

Each actor should be given a unique name. You can name an actor by using the actor specification window or by typing the name directly onto a Use Case diagram or into the browser.

To name an actor:

1.

Right−click the actor in the Use Case diagram or browser.

2.

Select Open Specification from the shortcut menu.

3.

In the Name field, enter the actor name.

OR

1.

Select the actor in the browser or on the Use Case diagram.

2.

Type in the actor name.

To add documentation to an actor:

1.

Select the actor in the browser.

2.

In the documentation window, type the actor description.

OR

1.

Right−click the actor in the browser or on the Use Case diagram.

2.

From the shortcut menu, select Open Specification.

3.

In the specification window, type the actor description in the Documentation area.

141

Chapter 4: Use Cases and Actors

Assigning an Actor Stereotype

As with use cases, you can assign a stereotype to an actor in the specifications window. However, if you change the stereotype of an actor, Rose will change the icon used to represent the actor on a Use Case diagram. Rather than using the actor symbol, Rose will use the standard rectangle that is used to represent a class.

Other than "Actor," there are no stereotypes provided for an actor. You can, however, define your own actor stereotypes and use these in your Rose model.

To assign an actor stereotype:

1.

Right−click the actor in the browser or on a Use Case diagram.

2.

Select Open Specification from the shortcut menu.

3.

In the Stereotype field, enter the actor stereotype.

Warning If you change the stereotype of an actor, Rose will no longer display the actor using the UML actor symbol. Rose will treat the actor like any other class.

Setting Actor Multiplicity

You can specify in Rose how many instances of a particular actor you expect to have. For example, you may want to know that there are many people playing the role of the customer actor, but only one person playing the role of the manager actor. You can use the Multiplicity field to note this.

Rose provides you with several multiplicity options:

Multiplicity

Meaning

0..0

Zero

0..1

Zero or one

0..n

Zero or more

1..1

Exactly one

1..n

One or more

n (default)

Many

Or, you can enter your own multiplicity options, using one of the following formats:

Format

Meaning

<number>

Exactly <number>

<number 1>..<number 2>

Between <number 1> and <number 2>

<number>..n

<number> or more

<number 1>,<number 2>

<number 1> or <number 2>

<number 1> , <number 2> .. <number 3>

Exactly <number 1> or between <number

 

2> and <number 3>

142

Chapter 4: Use Cases and Actors

<number 1> .. <number 2> , <number 3> .. <number 4>

Between <number 1> and <number 2> or

 

between <number 3> and <number 4>

To set actor multiplicity:

 

1.

Right−click the actor in the browser or on a Use Case diagram.

2.

Select Open Specification from the shortcut menu.

3.

Select the Detail tab.

4.

Select from the Multiplicity drop−down list box, or type in the actor's multiplicity using one of the formats listed above.

Creating an Abstract Actor

An abstract actor is an actor that has no instances. In other words, the actor's multiplicity is exactly zero. For example, you may have several actors: hourly employee, salaried employee, and temporary employee. All of these are types of a fourth actor, employee. However, no one in the company is just an employee—everyone

is either hourly, salaried, or temporary. The employee actor just exists to show that there is some commonality between hourly, salaried, and temporary employees.

There are no instances of an employee actor, so it is an abstract actor. Figure 4.19 shows an example of an abstract actor called "employee."

Figure 4.19: Abstract actor

To create an abstract actor:

1.

Create the actor in the browser or on a Use Case diagram.

2.

Right−click the actor in the browser or on the diagram.

3.

Select Open Specification from the shortcut menu.

4.

143

Chapter 4: Use Cases and Actors

Select the Detail tab.

5.

Check the Abstract check box.

Viewing Relationships for an Actor

The Relations tab in the actor specification window lists all of the relationships in which the actor participates. Figure 4.20 shows the Relations tab of the window. This tab includes all relationships the actor has with use cases, as well as the relationships to other actors. The list includes the relationship name and the actors or use cases that participate in the relationship. From this tab, you can view, add, or delete relationships.

Figure 4.20: Actor specification window's Relations tab

To view the relationships for an actor:

1.

Right−click the actor in the browser or on a Use Case diagram.

2.

Select Open Specification from the shortcut menu. The relationships will be listed on the Relations tab.

To view the relationship specifications:

1.

Double−click the relationship in the list.

2.

The relationship specification window will appear. (See the upcoming "Working with Relationships" section for a detailed description of relationship specifications.)

OR

1.

Right−click the relationship in the list.

2.

144