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

Chapter 4: Use Cases and Actors

Select Browse → Specification, or press Ctrl+B.

Naming a Use Case

Each use case in the model should be given a unique name. The use case should be named from the perspective of your customer, as the use cases will help determine the project scope. The use case name should also be implementation−independent. Try to avoid phrases, such as Internet, that tie the use case to a specific implementation. Use cases are typically named with verbs or short verb phrases.

There are two ways to name a use case. You can use the use case specification window or name the use case directly on the diagram.

To name a use case:

1.

Select the use case in the browser or on the Use Case diagram.

2.

Type the use case name.

OR

1.

Right−click the use case in the Use Case diagram or browser.

2.

Select Open Specification from the shortcut menu.

3.

In the Name field, enter the use case name.

To add documentation to a use case:

1.

Select the use case in the browser.

2.

In the documentation window, type the use case description.

OR

1.

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

2.

From the shortcut menu, select Open Specification.

3.

In the specification window, type the use case description in the Documentation area.

131

Chapter 4: Use Cases and Actors

Viewing Participants of a Use Case

You may want to see a listing of all of the classes and operations that participate in a particular use case. As the project progresses and you add or change requirements, it can be very helpful to know what classes might be affected by the change. In our airline example, we will need to know which classes are used by which use case as the requirements evolve and the use cases change.

Even after the system is complete, you may need an inventory of which classes are included in each use case. As the system moves into maintenance mode, you will need to control the scope of upgrades and changes. In Rose, you can view the use case participants using the Report menu.

To view the classes and operations participating in a use case:

1.

Select the use case on a Use Case diagram.

2.

Select Report → Show Participants in UC.

3.

The Participants window will appear, as shown in Figure 4.13.

Figure 4.13: Use case Participants window

Checking the Display Parent check box will display the package that owns each of the classes participating in the use case. The parent appears in parentheses after the class or operation name.

Checking the Display Type check box will add a notation next to each item in the list box to let you know whether the item is a class or an operation. The type appears in parentheses after the class or operation name.

Use the Components, Classes, and Operations check boxes to control whether components, classes, operations, or all three appear in the list box. Use the Open It button to view the specifications for an item in the list, and use the Goto It button to select the item in the browser.

Assigning a Use Case Stereotype

In UML, stereotypes are used to help you categorize your model elements. Say, for example, you had two primary types of use cases, type A and type B. You can create two new use case stereotypes, A and B. Stereotypes aren't used very often for use cases; they are used more for other model elements, such as classes and relationships. However, you do have the option of adding a use case stereotype if you'd like.

To assign a use case stereotype:

1.

132

Chapter 4: Use Cases and Actors

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

2.

Select Open Specification from the shortcut menu.

3.

Enter the stereotype in the Stereotype field.

Assigning a Priority to a Use Case

As you define your use cases, you might want to assign a priority to each. By adding priorities, you'll know in what order you'll be working on the use cases as the project progresses. In the use case specification in Rose, you can enter the use case priority description using the Rank field.

To assign a priority to a use case:

1.

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

2.

Select Open Specification from the shortcut menu.

3.

On the General tab, enter the priority in the Rank field.

Creating an Abstract Use Case

An abstract use case is one that is not started directly by an actor. Instead, an abstract use case provides some additional functionality that can be used by other use cases. Abstract use cases are the use cases that participate in an includes or extends relationship. Figure 4.14 includes examples of abstract use cases.

Figure 4.14: Abstract use cases

In this example, "Check Credit" is an abstract use case. The actor will run either the "Purchase Ticket" or "Change Reservation" use case, but not the "Check Credit" use case directly. See the section later in this chapter titled "Working with Relationships" for a description of how to draw the arrows between the use cases.

To create an abstract use case:

1.

Create the use case in the browser or on a Use Case diagram.

2.

133

Chapter 4: Use Cases and Actors

Right−click the use case in the browser or on the diagram.

3.

Select Open Specification from the shortcut menu.

4.

Check the Abstract check box.

Viewing Diagrams for a Use Case

In the use case specifications, you can see all of the activity diagrams, Sequence diagrams, Collaboration diagrams, Class diagrams, Use Case diagrams, and Statechart diagrams that have been defined under the use case in the browser. Figure 4.15 shows the Diagrams tab in the use case specification window. On this tab, you will see the Rose icons that indicate the type of diagram, as well as the diagram name. Double−clicking any of the diagrams will open the diagram in the diagram window.

Figure 4.15: Use case specification window's Diagrams tab

To view the diagrams for a use case:

1.

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

2.

Select Open Specification from the shortcut menu.

3.

The diagrams will be listed on the Diagrams tab of the specification window.

134

Chapter 4: Use Cases and Actors

OR

Look through the browser. The diagrams for the use case will appear underneath the use case in the browser.

To open a diagram for a use case:

Double−click the diagram name on the Diagrams tab of the use case specification window.

OR

1.

Right−click the diagram name on the Diagrams tab of the use case specification window.

2.

Select Open Diagram from the shortcut menu.

OR

Double−click the diagram in the browser.

To add a diagram to a use case:

1.

Right−click anywhere inside the Diagrams tab of the use case specification window.

2.

From the shortcut menu, select the type of diagram (Use Case, Sequence, Collaboration, State, or Class) you want to add.

3.

Enter the name of the new diagram.

OR

1.

Right−click the use case in the browser.

2.

Select New (Activity Diagram, Collaboration Diagram, Sequence Diagram, Class Diagram, Use Case Diagram) from the shortcut menu.

3.

Enter the name of the new diagram.

To delete a diagram from a use case:

1.

Right−click the diagram name on the Diagrams tab of the use case specification window.

2.

Select Delete from the shortcut menu.

135