CHAPTER 5 STATE MODELING 5 STATE MODELING State

  • Slides: 12
Download presentation
CHAPTER 5 STATE MODELING

CHAPTER 5 STATE MODELING

5. STATE MODELING � State Model consists of multiple state diagrams – one for

5. STATE MODELING � State Model consists of multiple state diagrams – one for each class with important temporal behavior � State diagrams relate events and states � Events � States � Transitions and Conditions � State Diagram Behavior

5. 1 EVENTS An occurrence at a point in time � Happens instantaneously with

5. 1 EVENTS An occurrence at a point in time � Happens instantaneously with regard to the time scale of an application � Two events that are causally unrelated are said to be concurrent – no effect on each other � Events include error conditions & normal occurrences � Examples : Transaction Aborted ; Time Out � Three Kinds of Events � Signal Event � Change Event � Time Event �

5. 1 THREE KINDS OF EVENTS � � � 5. 1. 1 Signal Event

5. 1 THREE KINDS OF EVENTS � � � 5. 1. 1 Signal Event � Signal : An explicit message - one way transmission of info from one object to another � Example Traffic Light � Signal event : It’s an occurrence in time � UML Notation of Signal in a class � Keyword “Signal” in guilemets << >> 5. 1. 2 Change Event � A event that is caused by the satisfaction of a boolean expression � UML Notation � Keyword “when” followed by paranthesized boolean expression � When (battery power < lowerlimit) 5. 1. 3 Time Event � An event that is caused by the occurrence of an absolute time or the elapse of a time interval � UML Notation � Keyword “when” - in parathesis expression involving time � Eg: when (date = September 5 2015) � Keyword “after” - in paranthesis expression that evaluates to a time duration � Eg: after (10 seconds)

5. 2 STATES � An abstraction of the values & links of an object

5. 2 STATES � An abstraction of the values & links of an object � Often a verb with a suffix of “ing” � Phone states - Waiting; Dialing � UML Notation �A rounded box containing a optional state name � Convention: State name in bold, center & near the top of the box with Capitalize � Various Book Characterization of States - Refer

5. 3 TRANSITIONS & GUARD CONDITIONS � Transition: Instantaneous change from one state to

5. 3 TRANSITIONS & GUARD CONDITIONS � Transition: Instantaneous change from one state to another � Guard Conditions(GC): Boolean expression that must be true in order for a transition to occur � UML Notation: � Transition: A line from the origin state to the target state. An arrow head points to the target. � Guard Condition: Optionally listed in square brackets �A GC triggers only once is different from Change Event which needs to be satisfies all time.

5. 4 STATE DIAGRAM �A graph whose nodes are states & whose arcs are

5. 4 STATE DIAGRAM �A graph whose nodes are states & whose arcs are transition between states � State names must be unique within the scope of a state diagram � UML Notation �A state diagram is a rectangle with its name in a small pentagonal tag in the upper left corner � 5. 4. 1 Sample State Diagram � 5. 4. 2 One shot State Diagram � Represents final states Object with finite lives and have initial &

5. 5 STATE DIAGRAM BEHAVIOR 5. 5. 1 ACTIVITY EFFECTS � Activity: Actual behavior

5. 5 STATE DIAGRAM BEHAVIOR 5. 5. 1 ACTIVITY EFFECTS � Activity: Actual behavior that can be worked by any number of effect � Effect: A reference to a behavior that is executed in response to an event � An activity may be performed upon a transition or event within a state � UML Notation � “/” & the name of the activity following the event that causes it � “do” keyword for ongoing activity

5. 5. 2 DO ACTIVITIES �A do activity is an activity that continues for

5. 5. 2 DO ACTIVITIES �A do activity is an activity that continues for an extended time � A do activity can only occur within a state & cannot be attached to a transition

5. 5. 3 ENTRY & EXIT ACTIVITIES Activities can be bound to entry or

5. 5. 3 ENTRY & EXIT ACTIVITIES Activities can be bound to entry or to exit from a state or on transition � If a state has multiple activities they are performed in order � Activities on incoming transition � Entry activities � Do activities � Exit activities � Activities on the outgoing transition � Any event can occur within a state & cause an activity to be performed � Self transition: Causes entry & exit activities to be executed �

5. 5. 4 COMPLETION TRANSITION � An arrow without an event name indicates an

5. 5. 4 COMPLETION TRANSITION � An arrow without an event name indicates an automatic transition that fires when the activity associated with the source state is completed � Such unlabelled transition are called completion transition as they are triggered by completion of activity in the source state

5. 5. 5 SENDING SIGNALS � From one object if a signal is sent

5. 5. 5 SENDING SIGNALS � From one object if a signal is sent to another object � 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 race condition