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

Chapter 4: Use Cases and Actors

like this:

The synchronizations are displayed as solid bars, and show where the logic forks and where it comes back together. A synchronization can be either horizontal or vertical.

Working with Use Cases in Rational Rose

In this section, we'll review how to create, update, and delete use cases and Use Case diagrams in Rose. We'll look at the Use Case Diagram toolbar, which can be used to add use cases, actors, relationships, and other elements to the Use Case diagrams. Then, we'll discuss creating, deleting, and setting the specifications of a use case in Rose.

It's not unusual to create a number of Use Case diagrams for a given project. Each would show a different subset of the use cases and actors. Rose provides you with one default Use Case diagram called Main, which can be used to show just the packages of use cases and actors, or show all the use cases and actors if you prefer. You can create as many Use Case diagrams as you need in a Rose model.

The Use Case Diagram Toolbar

When a Use Case diagram is opened, the Diagram toolbar changes to show icons used in Use Case diagrams. In the toolbar, Rose provides shortcuts for all of the commonly used functions for a Use Case diagram. Some of the buttons you will have available are shown in Table 4.1. In the remainder of this chapter, we'll discuss how to use each of these toolbar buttons to add use cases, actors, and other details to your Use Case diagrams.

Tip The buttons below are the defaults for the toolbar. As with any other toolbar, Rose toolbars can be customized. If you do not see all of the buttons listed, right−click the toolbar and select Customize.

Table 4.1: Icons in the Use Case Diagram Toolbar

Icon

Button

Purpose

 

Selects/Deselects an Item

Returns the cursor to an arrow so you can select an item.

 

 

 

123

 

Chapter 4: Use Cases and Actors

 

 

 

 

Text Box

Adds a text box to the diagram.

 

 

 

 

Note

Adds a note to the diagram.

 

 

 

 

Anchor Note to Item

Connects a note to a use case or actor on the diagram.

 

 

 

 

Package

Adds a new package to the diagram.

 

 

 

 

Use Case

Adds a new use case to the diagram.

 

 

 

 

Actor

Adds a new actor to the diagram.

 

 

 

 

Unidirectional Association

Draws a relationship between an actor and a use case.

 

 

 

 

Dependency or Instantiates

Draws a dependency between items on the diagram.

 

 

 

 

Generalization

Draws a includes or an extends relationship between use cases, or

 

 

draws an inheritance relationship between actors.

Creating Use Case Diagrams

In Rose, Use Case diagrams are created in the Use Case view. The Use Case view contains all of the following:

Use cases

Actors

Communication relationships between use cases and actors

Includes and extends relationships between use cases

Actor generalization relationships

Use Case diagrams

Activity diagrams

Use Case realizations

Sequence and Collaboration diagrams

We'll talk about all of the above except Sequence and Collaboration diagrams, which we'll cover in Chapter 5, "Object Interaction." The Use Case view is largely implementation−independent. The use cases and actors describe the project scope without getting into implementation details like the programming language that will be used. We will add implementation details starting with the Sequence diagrams in Chapter 5.

124

Chapter 4: Use Cases and Actors

Rose provides you with one default Use Case diagram called Main. You can create as many additional diagrams as you need to model your system.

To access the Main Use Case diagram, do the following:

1.

Click the + (plus sign) next to the Use Case view in the browser to open it.

2.

The Main Use Case diagram will be visible. Note that Use Case diagrams in Rose have the following icon on their left:

3.

Double−click the Main diagram to open it. The title bar will change to include [Use Case Diagram: Use Case View / Main].

To create a new Use Case diagram:

1.

Right−click the package Use Case view in the browser.

2.

Select New → Use Case Diagram from the shortcut menu, as shown in Figure 4.8.

Figure 4.8: Adding a new Use Case diagram

3.

With the new diagram selected, type in the name of your new diagram.

4.

Double−click the name of your new diagram in the browser to open it.

To open an existing Use Case diagram:

1.

125

Chapter 4: Use Cases and Actors

Locate the Use Case diagram in the Use Case view in the browser.

2.

Double−click the Use Case diagram's name to open it.

OR

1.

Select Browse → Use Case Diagram. The window displayed in Figure 4.9 will appear.

Figure 4.9: Opening an existing Use Case diagram

2.

In the Package list box, select the package that contains the diagram you want to open.

3.

In the Use Case Diagrams list box, select the diagram you want to open.

4.

Press OK.

To add an item to a Use Case diagram, use the toolbar buttons as described in the sections later in this chapter to add use cases, actors, and relationships to the diagram.

There are two ways to remove an item from a Use Case diagram. The first will remove the item from the open diagram, but will leave the item in the browser and on other diagrams. To remove an item from the current diagram only, highlight the item in the diagram and press the Delete key. The second method will delete the item from the entire model—from all diagrams as well as the browser. To remove an item from the entire model, highlight the item in the browser, right−click to see the shortcut menu, and select Delete from the shortcut menu. Or you can highlight the item in the diagram and press Ctrl+D.

Deleting Use Case Diagrams

You may need to delete some of the Use Case diagrams you've created. Toward the beginning of a project, it's not uncommon to create many Use Case diagrams as you brainstorm the scope. Some of the diagrams may contain the use cases, others will show the actors, and still others will show a subset of the use cases and the actors. As the project goes along, you may find the need to clean up some of these old diagrams. You can delete a Use Case diagram directly in the browser. Be careful, though—once you've deleted a diagram, you cannot undo the deletion.

To delete a Use Case diagram:

1.

126