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

Chapter 4: Use Cases and Actors

An inheritance relationship suggests that one actor or use case, for example, has some base characteristics that are shared by other actors or use cases. All actors or use cases that have a generalization relationship with it will "inherit" those base characteristics.

To add a generalization:

1.

Add the actors or use cases to the Use Case diagram.

2.

Select the Generalization button from the toolbar.

3.

Drag from the actor or use case to the generalized actor or use case.

To delete a generalization relationship:

1.

Select the relationship on the Use Case diagram.

2.

Select Edit → Delete from Model, or press Ctrl+D.

Working with Activity Diagrams

With Rose, you can create one or more activity diagrams for a use case. Activity diagrams are typically used to model the flow of events through the use case. Any activity diagrams for a use case will appear in the browser, underneath the appropriate use case.

The Activity Diagram Toolbar

The Activity Diagram toolbar is used to add activities, transitions, objects, and other elements to an activity diagram. Table 4.2 lists the icons in the Activity Diagram toolbar and explains their meaning.

Table 4.2: 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.

 

 

 

 

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.

 

 

 

 

State

Adds a state for an object.

 

 

 

 

Activity

Adds a new activity to the diagram.

 

 

 

149

Chapter 4: Use Cases and Actors

 

Start State

Shows where the workflow begins.

 

 

 

 

End State

Shows where the workflow ends.

 

 

 

 

State Transition

Adds a transition from one activity to another.

 

 

 

 

Transition to Self

Adds a transition from one activity to itself.

 

 

 

 

Horizontal Synchronization

Adds a horizontal synchronization.

 

 

 

 

Vertical Synchronization

Adds a vertical synchronization.

 

 

 

 

Decision

Adds a decision point in the workflow.

 

 

 

 

Swimlane

Adds a swimlane (usually used in business modeling).

 

 

 

 

Object

Adds an object to the diagram.

 

 

 

 

Object Flow

Connects an object to an activity.

 

 

 

Creating Activity Diagrams

To add an activity diagram, we use the browser window. Once the diagram is created, we can add activities, transitions, and other activity diagram elements. In this section, we'll discuss the different pieces of an activity diagram and how to add them.

To add an activity diagram:

1.

Right−click the use case in the browser.

2.

Select New → Activity Diagram.

3.

If this is the first activity diagram for a use case, Rose will create an entry titled State/Activity Model under the use case in the browser. The new activity diagram, and any other activity diagrams for this use case, will be placed under this State/Activity Model entry.

4.

Type the name of the new diagram.

Adding Activities and Actions

An activity is a step in the flow. Activities are shown on the diagrams as rounded rectangles. We can also add actions to the activity to show any detailed steps within the activity. There are four types of actions: those that occur when entering the activity, those that occur while exiting the activity, those that occur while inside the activity, and those that occur upon a specific event.

To add an activity:

1.

Select the Activity icon from the toolbar.

2.

150

Chapter 4: Use Cases and Actors

Click anywhere inside the diagram to place the activity.

3.

Type in the activity name.

To add an action:

1.

Right−click the activity.

2.

Select Open Specification.

3.

Select the Actions tab.

4.

Right−click anywhere in the whitespace within the tab and select Insert.

5.

A new action will be added to the list. Its default type will be Entry.

6.

Double−click the new action (the word Entry). The action specification window will open.

7.

In the When drop−down list box, select the On Entry, On Exit, Do, or On Event option.

8.

If you selected On Event, enter the event, any arguments, and the condition in the appropriate fields.

9.

Enter the name of the action in the Name field.

10.

Press OK to return to the activity specification window.

11.

To delete an action, right−click it on the Actions tab of the activity specification window and select Delete.

12.

Right−click to enter another action, or press OK to close the activity specification window.

Adding Objects and Object Flows

An object is an entity that is affected by or used by the workflow. We can model both the object and the state that the object is in. We can also show how an object is affected by or used by a workflow through object flows. A dashed arrow between an object and an activity represents an object flow.

To add an object:

1.

151

Chapter 4: Use Cases and Actors

Select the Object icon from the toolbar.

2.

Click anywhere inside the diagram to place the object.

3.

Type the object's name.

4.

Right−click and select Open Specification.

5.

If you have defined a class for the object, select that class in the Class field.

6.

If you would like to mark the object's state, select a state from the drop−down list box in the State field. If there are no available states or if you'd like to add one, select <new>. The State Specification window will open. Enter the name of the new state and press OK.

To add an object flow:

1.

Select the Object Flow icon from the toolbar.

2.

Drag and drop from the activity that changes the object to the object itself, or from the object to the activity that uses it.

3.

Rose will draw an object flow (dashed arrow).

Adding Transitions and Guard Conditions

A transition shows the movement from one activity to another. We can add an event to the transition that shows what event triggers the transition. We can also add a guard condition, which controls whether or not the transition can occur.

To add a transition:

1.

Select the Transition icon from the toolbar.

2.

Drag and drop from one activity to another.

3.

Rose will draw a transition between the two activities.

To add an event:

1.

152

Chapter 4: Use Cases and Actors

Right−click the transition.

2.

Select Open Specification. The transition specification window will appear.

3.

Type the event in the Event field. If there are any arguments for the event, enter them in the Arguments field.

To add a guard condition:

1.

Right−click the transition.

2.

Select Open Specification. The transition specification window will appear.

3.

Select the Detail tab.

4.

Type the guard condition in the Guard Condition field.

Note You can also add guard conditions directly on the transition arrow. Enclose the guard condition within square brackets.

Adding Synchronizations and Decisions

Finally, we can show synchronous activity and conditions in the logic of the flow by using of horizontal synchronizations, vertical synchronizations, and decision points.

To add a synchronization:

1.

Select the Horizontal or Vertical Synchronization icon from the toolbar.

2.

Click anywhere inside the diagram to place the synchronization.

3.

Draw transitions from activities to the synchronization or from the synchronization to one or more activities.

To add a decision:

1.

Select the Decision icon from the toolbar.

2.

Click anywhere inside the diagram to place the decision.

3.

153