Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Software Engineering Dr. K. T. Tsang Lecture 8 State modeling

Similar presentations


Presentation on theme: "1 Software Engineering Dr. K. T. Tsang Lecture 8 State modeling"— Presentation transcript:

1 1 Software Engineering Dr. K. T. Tsang Lecture 8 State modeling http://www.uic.edu.hk/~kentsang/SWE/SWE.htm

2 Events An event is an occurrence at a point in time. It happens instantaneously compared with the time scale in time, can be considered as atomic.

3 Signal event A signal is a one-way transmission of information from one object to another. A signal event is the event of sending or receiving a signal. Signals can be grouped into signal classes, to show common structure and behavior. The UML notation is: > MouseButtonPushed button location

4 A change event is an event caused by the satisfaction of a boolean expression. The underlying expression is continually tested. Whenever the expression changes from false to true, the event happens. The UML notation for change event is: Change event when (roomTemperature < heating_set_point)

5 States A “State” is an abstraction (a group) of values and links of an object, that characterizes its gross behavior, e.g. –a bank is either solvent or insolvent, depending on whether its assets exceed its liability; –a phone line is in a state of dialing or waiting depending on whether the receiver is lifted or not. States are equivalence classes of values and links for an object. State model specifies allowable sequence of changes to objects of a given class. The UML notation for a state is a rounded box.

6 Life of an object & its states Objects in a class have a finite number of states. During the lifetime of an object, it can only be in one state at a time. It may parade from one state to another. Events are points in time, and states are intervals of time. Events mark the beginning and end of a state. time receiver liftedfirst digit dialed Dial tone DialingWaiting States of a phone-line events

7 Transition A transition is an instantaneous change from one state to another. A transition is fired when an object changes from the source state to the target state. A guard condition is a boolean expression that must be true in order for a transition to occur.

8 Guard condition in transition: example North/south may go straight North/south may turn left East/west may turn left East/west may go straight timeout timeout [cars in E/W left lanes] timeout [cars in N/S left lanes] timeout [no car in E/W left lanes] timeout [no car in N/S left lanes] Traffic control signals Fig.5.7 p.95 B&R

9 State diagrams -- A graph whose nodes are states and whose directed arcs are transitions between states. It specifies the state sequences cause by event sequences. A state diagram describes all or part of the behavior of the objects of a given class. State names must be unique within scope of a state diagram.

10 State diagram: example- a phone line Fig.5.8 p.97 (no nested states)

11 State diagram example: chess White’s turn Black’s turn Black more White more checkmate stalemate Fig.5.9 p.98

12 State diagram example: chess White’s turn Black’s turn Black more White more checkmate stalemate X X X Black wins White wins draw Start Fig.5.10 p.98 With entry & exit points

13 Activities & effects An effect is a behavior executed in response to an event. An activity is the behavior that can be invoked by any number of effects. An activity may be performed upon a transition, upon the entry or exit from a state, or upon some other event within a state. Notation: a slash “/” and the name of the activity, following the event that causes it.

14 Example - activities Idle Menu visible Right button up / erase pop-up menu Right button down / display pop-up menu Cursor moved / highlight menu item Activities for pop-up menu Fig.5.12 p.100 Self-transition

15 Do-Activities A do-activity is an activity that continues for an extended time. Paper jam do / flash warning light

16 Entry & exit activities Closed Opening Open Closing Door closed / motor off Door open / motor off Depress / motor up Depress / motor down Garage door opener – example fig.5.14 p.101 Activities following events

17 Entry & exit activities Closed entry / motor off Opening entry / motor up Open entry / motor off Closing entry / motor down Door closed Door open Depress Garage door opener – example fig.5.15 p.101 Activities bound to entry of states

18 More on events & activities Event can occur within a state and causes activity to be performed. Entry & exit are only 2 examples of events that can occur. Self-transition states cause the entry/exit activities to be executed.

19 Completion transition Often the sole purpose of a state is to perform a sequential activity. An arrow without an event name is an automatic transition that fires when the activities associated with source state is completed. This kind of transition is called “Completion transition”.

20 Signals An object can send a signal (this action is an activity) to other object/objects (single object or a set of objects). If the target is a group of objects, each of them receives a copy of the signal concurrently, and responses independently. If an object can receive signals from more than one object, the order in which concurrent signals are received may affect the final state - this is called a race condition. Concurrent systems may contain unwanted race conditions that must be avoided by careful design.

21 Reading for this lecture Chapter 5 Blaha & Rumbaugh


Download ppt "1 Software Engineering Dr. K. T. Tsang Lecture 8 State modeling"

Similar presentations


Ads by Google