Outline: Key Concepts & Their UML Notations Basic State Diagram UML Notations Examples Exercises

21
Fall 2010 CS4310 Requirements Engineering UML: Dynamic Modeling Dr. Guoqiang Hu Department of Computer Science UTEP 1

description

Fall 2010 CS4310 Requirements Engineering UML: Dynamic Modeling Dr. Guoqiang Hu Department of Computer Science UTEP. 1. Outline: Key Concepts & Their UML Notations Basic State Diagram UML Notations Examples Exercises Nested State Diagram, Nested State Sequence Diagram Activity Diagram. - PowerPoint PPT Presentation

Transcript of Outline: Key Concepts & Their UML Notations Basic State Diagram UML Notations Examples Exercises

Page 1: Outline: Key Concepts & Their UML Notations Basic State Diagram UML Notations Examples Exercises

Fall 2010

CS4310 Requirements Engineering

UML: Dynamic Modeling

Dr. Guoqiang Hu

Department of Computer Science

UTEP

1

Page 2: Outline: Key Concepts & Their UML Notations Basic State Diagram UML Notations Examples Exercises

Outline:

1. Key Concepts & Their UML Notations

2. Basic State Diagram UML Notations

3. Examples

4. Exercises

5. Nested State Diagram, Nested State

6. Sequence Diagram

7. Activity Diagram

2

Page 3: Outline: Key Concepts & Their UML Notations Basic State Diagram UML Notations Examples Exercises

3

1 Key Concepts & Their UML Notations

1.1 State model

Describes the sequences of operations of objects that occur in response to stimuli

Consists of multiple state diagrams, one for each class with temporal behavior that is important to an application

1.2 State

An abstraction of the values and links of an object: sets of values and links grouped together into a state according to the gross behavior of the object

Ignore attributes that do not affect the behavior of the object, and lump together in a single state all combinations of values and links with the same response to events

Solvent Insolvent PoweredWaiting Dialing

Page 4: Outline: Key Concepts & Their UML Notations Basic State Diagram UML Notations Examples Exercises

4

1.3 Event

An occurrence at a point in time

Can be causally related or unrelated (concurrent)

The most common types of event:

1.Signal event: Sending or receiving a signal (message)

2.Change event: Caused by the satisfaction of a boolean expression (continuously tested)

when (room temperature < heating set point)

when (room temperature < cooling set point)

3.Time event: Caused by the occurrence of an absolute time or the elapse of a time interval

when (date = October 28, 2010)

after (10 seconds)

Page 5: Outline: Key Concepts & Their UML Notations Basic State Diagram UML Notations Examples Exercises

5

1.4 Event vs. state

Events: points in time

State: intervals in time

All events are ignored in a state, except those for which behavior is explicitly prescribed. The response may include the invocation of behavior or a change of state.

power turned on

power turned off

power turned on

time

Powered Not powered

1.5 Transitions and conditions

Transitions: An instantaneous change from one state to another

Guard condition: A boolean expression that must be true for a transition to occur (only checked once)

Page 6: Outline: Key Concepts & Their UML Notations Basic State Diagram UML Notations Examples Exercises

6

event (attribs) [condition] / effect

State diagram name

2 Basic State Diagram UML Notation

State1

do / activity

event / effect

State2

For example:

right button down / display pop-up menuIdle

Menu

visible

Activities for pop-up menu

right button up / erase pop-up menu

cursor moved / highlight menu item

Page 7: Outline: Key Concepts & Their UML Notations Basic State Diagram UML Notations Examples Exercises

7

For example:

Paper jam

do / flash warning light

Do-activity for copy machine

White’s turn

Black’s turn

black moves

Black wins

Draw

White wins

checkmate

checkmate

stalemate

stalemate

For example: Initial & final state

white

moves

Chess

Page 8: Outline: Key Concepts & Their UML Notations Basic State Diagram UML Notations Examples Exercises

8

depress / motor up

DoorOpener

3 Examples (1)

ClosedOpen

Opening

Closing

door open / motor off

depress / motor down

depress / motor up

door closed / motor off

Page 9: Outline: Key Concepts & Their UML Notations Basic State Diagram UML Notations Examples Exercises

9

timeout

SmartTrafficLights

3 Examples (2)

North/South

May go straight

timeout [cars in N/S left lanes]

North/South

May turn left

East/West

May go straight

East/West

May turn left

timeout

timeout [cars in E/W left lanes]

timeout [no cars in E/W left lanes]

timeout [no cars in N/S left lanes]

Page 10: Outline: Key Concepts & Their UML Notations Basic State Diagram UML Notations Examples Exercises

4 In-Class Exercises (1)

Draw a state diagram for a digital watch (8 minutes)

The watch has a single mode button and a single advance button. Pressing the mode button once and then pressing the advance button increments the hours by 1. Each press of the advance button increments the hour. Pressing the mode button the second time allows advancing the minutes by 1. Pressing the mode button a third time displays the current time. While displaying the current time, the advance button is ignored. Pressing the mode button allows the user to set the hour again.

10

Page 11: Outline: Key Concepts & Their UML Notations Basic State Diagram UML Notations Examples Exercises

DigitalWatch

4 In-Class Exercises (1)

Display

Current

Time

Set

Hours

Set

Minutes

Mode button

Mode button

Mode button

Advance / hours=(hours+1) mod 24

Advance /

min=(min+1) mod 60

11

Page 12: Outline: Key Concepts & Their UML Notations Basic State Diagram UML Notations Examples Exercises

4 In-Class Exercises (2)

Draw a state diagram for an office phone when making a call. (15 minutes)

Assume that the phone has keys for the digits 0-9, #, and *. It can detect when the receiver is on-hook or off-hook.

Hint: The phone is idle when the receiver is on-hook. Based on your past experiences, you can decide the possible states of the phone, for example, dialing, connecting, talking, etc.

12

Page 13: Outline: Key Concepts & Their UML Notations Basic State Diagram UML Notations Examples Exercises

4 In-Class Exercises (2)

13

Page 14: Outline: Key Concepts & Their UML Notations Basic State Diagram UML Notations Examples Exercises

5 Nested State Diagram, Nested State

14

Page 15: Outline: Key Concepts & Their UML Notations Basic State Diagram UML Notations Examples Exercises

5 Nested State Diagram, Nested State (cont’d)

15

Page 16: Outline: Key Concepts & Their UML Notations Basic State Diagram UML Notations Examples Exercises

5 In-Class Exercises (3)

Draw a state diagram for an automatic transmission (10 minutes).

The transmission can be in reverse, neutral, or forward. If it is in forward, it can be in first, second, or third gear. States first, second, and third are nested states of forward. Selecting “N” in any forward gear shifts the transmission to neutral. Selecting “F” in neutral always shifts the transmission to first, In any forward gear, stopping the car always shifts the transmission to first.

16

Page 17: Outline: Key Concepts & Their UML Notations Basic State Diagram UML Notations Examples Exercises

5 In-Class Exercises (3)

17

Page 18: Outline: Key Concepts & Their UML Notations Basic State Diagram UML Notations Examples Exercises

6 Sequence Diagram

18

Page 19: Outline: Key Concepts & Their UML Notations Basic State Diagram UML Notations Examples Exercises

6 Sequence Diagram (cont’d)

19

Page 20: Outline: Key Concepts & Their UML Notations Basic State Diagram UML Notations Examples Exercises

7 Activity Diagram

20

Page 21: Outline: Key Concepts & Their UML Notations Basic State Diagram UML Notations Examples Exercises

7 Activity Diagram (cont’d)

21