尊敬的 微信汇率:1円 ≈ 0.046166 元 支付宝汇率:1円 ≈ 0.046257元 [退出登录]
SlideShare a Scribd company logo
State Modeling
Introduction
• The structure of objects and their relationships to each other in
a system described by its static structure i.e. the class model.
• Some objects in a system have complex temporal behaviors,
which must be carefully design.
• Temporal phenomena that occur over an interval of time are
properly modeled with a state
• The state model examine changes to the objects and their
relationships over time
• The state model describes the sequence of operations that
occur in response to events (external stimuli)
Events
• occurrence at a point in time
– instantaneous
– often corresponds to verb in past tense
• e.g., alarm set, powered on
– or onset of a condition
• e.g., paper tray becomes empty, temperature drops below freezing
• may logically precede or follow another or may
be unrelated
– e.g., Flight 123 must depart DDN before it can arrive in Delhi
(causally related)
– e.g., Flight 123 may depart before or after flight 345 departs DDN
(causally unrelated)
• Concurrent event: causally unrelated events;
have no effect on one another
Kinds of events
Signal event:
– the event of sending or receiving of a signal
• Signal: an explicit one-way transmission of
information from one object to another
• may be parameterized
– E.g., stringEntered(“Foo”)
– sending of a signal by one object is a distinct
event from its reception by another
– Difference between signal and signal event
– every signal transmission is a unique
occurrence but we group them into signal
classes to indicate common structure and
behavior.
• E.g., IA flight 123 departs from DDN on Jan 11, 2013 is an
instance of FlightDeparture
Signal class - UML notation
<< signal >>
FlightDeparture
airline
flightNum
city
date
keyword “signal” in << >>
name of signal class
attributes
Kinds of Events
• Change event
– Event caused by satisfaction of a Boolean expression
– Intent: Expression continually tested; when changes from
false to true, the event happens
– UML Notation: keyword when followed by parenthesized
boolean expression
• when(room temperature < heating set point)
• when(room temperature > cooling set point)
• when(battery power < lower limit)
• when(tire pressure < minimum pressure)
Kinds of Events
• Time event
– Event caused by the occurrence of an absolute time or the
elapse of a time interval
– for absolute time the UML Notation: keyword when
followed by parenthesized expression involving time
• when (date = Jan 1, 2013)
– for time interval the UML Notation: keyword after followed
by parenthesized expression that evaluate to a time
duration
• after (n timeUnits)
• after(10 seconds)
States
• an abstraction of values and links of an object
• behavioral condition that persists in time
• according to gross behavior of objects, set of values
and links are grouped together into a state
• often corresponds to
– verbs with suffix of “-ing”
• e.g., Boiling, Waiting, Dialing
– the duration of some condition
• e.g., Powered, BelowFreezing
• UML Notation: a rounded box containing an
optional state name
Powered Waiting Dialing
Contd.
• In defining states
– ignore attributes that do not affect the behavior of the object
– lump together in a single state all combinations of values and links
with the same response to events
– E.g., except for leading 0’s & 1’s, the exact digits dialed do not affect
the control of the phone line, so we can define a state Dialing and
track the phone number as a parameter
• Objects in a class have a finite number of possible states
– Each object can only be in one state at a time
– At a given moment of time, the various objects for a class can exist
in a multitude of states
• A state specifies the response of an object to input events
– E.g., if a digit is dialed in state DialTone, the phone line drops the
dial tone and enters state Dialing;
– If the receiver is replaced in state DialTone, the phone line goes
dead and enters state Idle.
Symmetry between Events and States
• Events represent points in time
• State represent intervals of time. A state
corresponds to the interval between two events
received by an object
Power turned on Power turned off Power turned on
Powered Not Powered
Transitions and Conditions
• Transition: an instantaneous change in state
– triggered by an event
– Transition is said to fire upon the change from source to target
state
– Origin and target state of a transition are different states but
may be the same
– e.g., when a phone line is answered, the phone line transitions
from the Ringing state to the Connected state.
• Guard Condition:
– boolean expression that must be true for transition to occur
– checked only once, at the time event occurs; transition fires if
true
– E.g., when you go out in the morning (event), if the temperature
is below freezing (condition), then put on your gloves (next
state).
Enabling and firing of transitions
Transition is:
– enabled when source state is active and guard condition
satisfied
– fires when enabled and the triggering event occurs
Example below:
– enabled when current state is Editing and the form is
complete
– fires when the user presses the “OK” button
Editing Submitted
pressOK [form complete]
State Diagrams
• a graph whose nodes are states and whose
directed arcs are transitions between states
• specifies state sequences caused by event
sequences
• all objects in a class execute the state diagram for
that class; diagram models their common
behavior
– Note: state names are unique within the scope of
state diagram
– A class with more than one state has important
temporal behavior
– A class is temporarily important if it has a single state
with multiple responses to events
State diagrams
Graphical state-modeling notation:
– States: labeled rounded box
– Transitions: directed arcs, labeled by triggering event,
optional guard condition, and/or effects
Specifies the response of an object to input events
- ignores events except those for which behavior is
prescribed
Example:
S T
States
State diagrams
S T
States
Transition
Graphical state-modeling notation:
– States: labeled rounded box
– Transitions: directed arcs, labeled by triggering event,
optional guard condition, and/or effects
Specifies the response of an object to input events
- ignores events except those for which behavior is
prescribed
Example:
State diagrams
Graphical state-modeling notation:
– States: labeled rounded box
– Transitions: directed arcs, labeled by triggering
event, optional guard condition, and/or effects
Example:
S T
event(attribs) [condition] / effect
States
EventTransition
• State diagrams can represent
– Continuous loops
• Do not care, how the loop is started
– One-shot life cycles
Phone Line example
“One-shot” state diagrams
• represent objects with finite lives
– have initial and finite states
• initial state - entered on object creation
• final state - entry implies destruction of object
Example
White’s
turn
Black’s
turn
white
moves
black
moves
checkmate
checkmate
stalemate
stalemate
Chess game
start state
Default final state
Example
White’s
turn
Black’s
turn
Black
wins
White
wins
Draw
white
moves
black
moves
checkmate
checkmate
stalemate
stalemate
Chess game
start state
Final
states
Example - entry and exit points
White’s
turn
Black’s
turn
white
moves
black
moves
checkmate
checkmate
stalemate
stalemate
Chess game
Black wins
Draw
White wins
State Model
• multiple state diagrams, one for each class
with important temporal behavior
– diagrams interact by passing events and through
side effects of guard conditions
– events and guard conditions must match across
diagrams in the model
Details
– if more than one transition leaves a state, then the
first event to occur causes the corresponding
transition to fire
– if an event occurs and no transition matches it,
the event is ignored
– if more than one transition matches an event, only
one transition will fire but the choice is non-
deterministic
Activity Effects
• effect = reference to a behavior executed in
response to an event
– can be attached to a transition or a state
– listed after a slash (“/”)
– multiple effects separated with a “,” and are
performed concurrently
Activity Effects
• Activity = behavior that can be invoked by any
number of effects
• May be performed upon:
– a transition
– entry to or exit from a state
– some event within a state
• Notation:
– event / resulting-activity
Activities
Often useful to specify an activity that is
performed within a given state
– E.g., while in PaperJam state, the warning light
should be flashing
– E.g., on entry into the Opening state, the motor
should be switched on
– E.g., upon exit of the Opening state, the motor
should be switched off
Activity effects
Idle Menu visible
r_button_down / showPopup
r_button_up / hidePopup
Do-Activities
PaperJam
do/ flash warning light
• continue for an extended time
• can occur only within a state
• can not be attached to a transition
• include
• continuous operations, such as displaying a picture on a
television screen
• Sequential operations that terminate by themselves after an
interval of time
• may be performed for all or part of time that an object is in a state
• may be interrupted by event received during execution; event may
or may not cause state transition
Entry and Exit Activities
Opening
entry / motor up
exit / motor off
• can bind activities to entry to/ exit from a state
•All transitions into a state perform the same activity, in
which case it is more concise to attach the activity to the state
Order of activities
1. activities on incoming transition
2. entry activities
3. do-activities
4. exit activities
5. activities on outgoing transition
Events that cause transitions out of the state can interrupt
do-activities. If a do-activity is interrupted, the exit
activity is still performed
• In general, any event can occur within a state
and cause an activity to be performed.
• Entry and exit are only two examples of events
that can occur
• Difference between an event within a state
and self-transition: only the self-transition
causes the entry and exit activities to be
executed but an event within a state does not
Completion Transition
• triggered by completion of activity in the source
state
• Often the sole purpose of a state is to perform a
sequential activity.
• When the activity is completed, a transition to
another state fires
• An arrow without an event name indicates an
automatic transition that fires
State 1
do / blah()
State 2
Contd.
• If a state has one or more completion transitions, but
none of the guard conditions are satisfied, then the state
remains active and may become ‘stuck’.
• The completion event does not occur a second time
• Therefore no completion transition will fire later to
change the state
• So if a state has completion transition leaving it, normally
guard condition should cover every possible outcome.
• Do not use guard condition on a completion transition to
model waiting for a change of value
Sending signals
• A object can perform the activity of sending a signal to
another object.
• A system of objects interact by exchanging signals
• The activity “send target.S(attributes)” sends a signal S with
the given attributes to the target object.
• E.g., the phone line sends a connect(phone number) signal to
the switcher when a complete phone number has been dialed.
• A signal can be directed to a set of objects or a single object.
• If the target is a set of objects, each of them receives a
separate copy of the signal concurrently and independently
process the signal and determines whether to fire a transition
or not
• If an object receive signals from more than one object, the
order in which concurrent signals are received may affect the
final state (race condition)
Advanced state modeling
• Conventional state diagrams are sufficient for
describing simple systems but need additional
power to handle large problems
• Model complex system by using
– Nested state diagrams
– Nested states
– Signal generalization
– Concurrency
Nested state diagram
• Problem with flat state diagram
– Consider an object with n independent Boolean attributes
that affect control
– representing such object with a single flat state diagram
would require 2n states
• Expanding state
– Organize the model by having high-level diagram with sub
diagrams expanding certain states
– Submachine: a state diagram that may be invoked as part
of another state diagram (lower-level state diagram).
– UML Notation for submachine: list a local name followed
by a colon and the submachine name.
Nested state
• Nest states to show their commonality and share
behavior
• Composite state: state that encloses the nested
states.
– Labels in the outer contour
• A nested state receives the outgoing transitions
of its composite states
Example: Transmission
Transmission
Forward
Neutral
Reverse
1st 2nd 3rd
downshift
upshift
downshift
upshift
stop
push N push F
push N
push R
Signal Generalization
• Organize signals into generalization hierarchy with
inheritance of signal attributes
• View every actual signal as a leaf on a generalization
tree of signals.
• Received signal triggers transitions that are defined
for any ancestor signal type.
– E.g., typing an ‘a’ would trigger a transition on signal
Alphanumeric as well as signal KeyboardCharacter.
• A signal hierarchy permits different levels of
abstraction to be used in a model.
– E.g., some state might handle all i/p characters the same;
other states might treat control characters differently
from printing characters .
CONCURRENCY
• State model supports concurrency among
objects
• Object can act & change state independent of
one another.
• Sometime objects shares constraints that
causes their state changes
AGGREGATION CONCURRENCY
• State Aggregation means collection of state
diagrams , one for each part
• “and” relationship
• Aggregate state is one state from first diagram &
a state from second diagram & state from each
other diagram.
• Transition for one object depend on another
object that allows interaction between the state
diagram.
Concurrency within an Object
• Some objects can be partitioned into subsets of
attributes or links.
• Each of the partitioned subset has its own subdiagram.
• The state of the object comprises one state from each
subdiagram.
• The sub diagrams need not be independent; the same
event can cause transitions in more than one
subdiagram
• UML Notation- partition the composite state into
regions with dotted lines.
Synchronization of Concurrent
Activities
• Sometimes one object must perform two ( or
more) activities concurrently.
• The object must complete both activities
before it can progress to its next state.
Fork and Join
OR
Splitting control and Merging control
• FORK- A transition that forks indicates splitting
of control into concurrent parts.
• JOIN- Explicit merging of concurrent control
by a transition.
Relation of class model, state model
• A state diagram describes all or part of the
behavior of the objects of a given class.
• States = classes of values & link for an object
• State model of a class is inherited by its
subclasses. Subclass inherits both the state &
Transitions.
• It is also possible to refine an inherited state
diagram by expanding state into nested state or
concurrent sub diagrams.
Contd.
• State structure is related to and constrained
by class structure.
– A composite state is the aggregation of more than
one concurrent substate.
– Try to make the state diagrams of subclasses
independent of the state diagrams of their
superclasses.

More Related Content

What's hot

CS8592-OOAD Lecture Notes Unit-3
CS8592-OOAD Lecture Notes Unit-3CS8592-OOAD Lecture Notes Unit-3
CS8592-OOAD Lecture Notes Unit-3
Gobinath Subramaniam
 
Uml class-diagram
Uml class-diagramUml class-diagram
Uml class-diagram
ASHOK KUMAR PALAKI
 
State chart diagram
State chart diagramState chart diagram
State chart diagram
Preeti Mishra
 
Processes and threads
Processes and threadsProcesses and threads
Processes and threads
Satyamevjayte Haxor
 
Collaboration Diagram
Collaboration DiagramCollaboration Diagram
Collaboration Diagram
fahad_uaar
 
Uml Activity Diagram
Uml Activity DiagramUml Activity Diagram
Uml Activity Diagram
Niloy Rocker
 
5.state diagrams
5.state diagrams5.state diagrams
5.state diagrams
APU
 
INTRODUCTION TO UML DIAGRAMS
INTRODUCTION TO UML DIAGRAMSINTRODUCTION TO UML DIAGRAMS
INTRODUCTION TO UML DIAGRAMS
Ashita Agrawal
 
Uml diagrams
Uml diagramsUml diagrams
Uml diagrams
barney92
 
Software Engineering : Requirement Analysis & Specification
Software Engineering : Requirement Analysis & SpecificationSoftware Engineering : Requirement Analysis & Specification
Software Engineering : Requirement Analysis & Specification
Ajit Nayak
 
Domain class model
Domain class modelDomain class model
Domain class model
shekharsj
 
UML Architecture and Views
UML Architecture and ViewsUML Architecture and Views
UML Architecture and Views
Kumar
 
CS8592-OOAD Lecture Notes Unit-2
CS8592-OOAD Lecture Notes Unit-2CS8592-OOAD Lecture Notes Unit-2
CS8592-OOAD Lecture Notes Unit-2
Gobinath Subramaniam
 
UML
UMLUML
Lecture6 activity diagrams
Lecture6 activity diagramsLecture6 activity diagrams
Lecture6 activity diagrams
Shahid Riaz
 
Object oriented methodologies
Object oriented methodologiesObject oriented methodologies
Object oriented methodologies
naina-rani
 
Overview of UML Diagrams
Overview of UML DiagramsOverview of UML Diagrams
Overview of UML Diagrams
Manish Kumar
 
UML Diagrams
UML DiagramsUML Diagrams
UML Diagrams
Kartik Raghuvanshi
 
Class diagram- UML diagram
Class diagram- UML diagramClass diagram- UML diagram
Class diagram- UML diagram
Ramakant Soni
 
Object Oriented Design in Software Engineering SE12
Object Oriented Design in Software Engineering SE12Object Oriented Design in Software Engineering SE12
Object Oriented Design in Software Engineering SE12
koolkampus
 

What's hot (20)

CS8592-OOAD Lecture Notes Unit-3
CS8592-OOAD Lecture Notes Unit-3CS8592-OOAD Lecture Notes Unit-3
CS8592-OOAD Lecture Notes Unit-3
 
Uml class-diagram
Uml class-diagramUml class-diagram
Uml class-diagram
 
State chart diagram
State chart diagramState chart diagram
State chart diagram
 
Processes and threads
Processes and threadsProcesses and threads
Processes and threads
 
Collaboration Diagram
Collaboration DiagramCollaboration Diagram
Collaboration Diagram
 
Uml Activity Diagram
Uml Activity DiagramUml Activity Diagram
Uml Activity Diagram
 
5.state diagrams
5.state diagrams5.state diagrams
5.state diagrams
 
INTRODUCTION TO UML DIAGRAMS
INTRODUCTION TO UML DIAGRAMSINTRODUCTION TO UML DIAGRAMS
INTRODUCTION TO UML DIAGRAMS
 
Uml diagrams
Uml diagramsUml diagrams
Uml diagrams
 
Software Engineering : Requirement Analysis & Specification
Software Engineering : Requirement Analysis & SpecificationSoftware Engineering : Requirement Analysis & Specification
Software Engineering : Requirement Analysis & Specification
 
Domain class model
Domain class modelDomain class model
Domain class model
 
UML Architecture and Views
UML Architecture and ViewsUML Architecture and Views
UML Architecture and Views
 
CS8592-OOAD Lecture Notes Unit-2
CS8592-OOAD Lecture Notes Unit-2CS8592-OOAD Lecture Notes Unit-2
CS8592-OOAD Lecture Notes Unit-2
 
UML
UMLUML
UML
 
Lecture6 activity diagrams
Lecture6 activity diagramsLecture6 activity diagrams
Lecture6 activity diagrams
 
Object oriented methodologies
Object oriented methodologiesObject oriented methodologies
Object oriented methodologies
 
Overview of UML Diagrams
Overview of UML DiagramsOverview of UML Diagrams
Overview of UML Diagrams
 
UML Diagrams
UML DiagramsUML Diagrams
UML Diagrams
 
Class diagram- UML diagram
Class diagram- UML diagramClass diagram- UML diagram
Class diagram- UML diagram
 
Object Oriented Design in Software Engineering SE12
Object Oriented Design in Software Engineering SE12Object Oriented Design in Software Engineering SE12
Object Oriented Design in Software Engineering SE12
 

Viewers also liked

State Machine Diagram
State Machine DiagramState Machine Diagram
State Machine Diagram
Niloy Rocker
 
State diagram
State diagramState diagram
State diagram
Hareem Naz
 
Domain State model OOAD
Domain State model  OOADDomain State model  OOAD
Domain State model OOAD
Raghu Kumar
 
State Diagram
State DiagramState Diagram
Object Modeling Techniques
Object Modeling TechniquesObject Modeling Techniques
Object Modeling Techniques
Shilpa Wadhwani
 
State diagram railway reservation system
State diagram railway reservation systemState diagram railway reservation system
State diagram railway reservation systemmuthumeenakshim
 
Object Oriented Modeling and Design with UML
Object Oriented Modeling and Design with UMLObject Oriented Modeling and Design with UML
Object Oriented Modeling and Design with UML
Malek Sumaiya
 
Object Oriented Analysis and Design
Object Oriented Analysis and DesignObject Oriented Analysis and Design
Object Oriented Analysis and Design
Haitham El-Ghareeb
 
Bab 10 state diagram 2010
Bab 10 state diagram 2010Bab 10 state diagram 2010
Bab 10 state diagram 2010
donasiilmu
 
Beyond cons12
Beyond cons12Beyond cons12
Beyond cons12
Magdy Aly
 
Chapter 6 the modeling activity
Chapter 6   the modeling activityChapter 6   the modeling activity
Chapter 6 the modeling activity
arief_rudyanto
 
behavioral model (DFD & state diagram)
behavioral model (DFD & state diagram)behavioral model (DFD & state diagram)
behavioral model (DFD & state diagram)
Lokesh Singrol
 
Online examination system for sanothimi campus purshuram
Online examination system for sanothimi campus purshuramOnline examination system for sanothimi campus purshuram
Online examination system for sanothimi campus purshuram
Nawaraj Ghimire
 
Object modeling
Object modelingObject modeling
Object modeling
Anand Grewal
 
03 fsm how_toimplementai_state_20161006_jintaeks
03 fsm how_toimplementai_state_20161006_jintaeks03 fsm how_toimplementai_state_20161006_jintaeks
03 fsm how_toimplementai_state_20161006_jintaeks
JinTaek Seo
 
Ch02 3133
Ch02 3133Ch02 3133
Ch02 3133
durgedevita
 
Automatic Question Paper Generator
Automatic Question Paper GeneratorAutomatic Question Paper Generator
Automatic Question Paper Generator
Azharuddin Kazi
 
Online Examination System Report
Online Examination System ReportOnline Examination System Report
Online Examination System Report
Ankan Banerjee
 
E r diagram
E r diagramE r diagram
E r diagram
Nittaya Intarat
 
Umar Erd
Umar ErdUmar Erd

Viewers also liked (20)

State Machine Diagram
State Machine DiagramState Machine Diagram
State Machine Diagram
 
State diagram
State diagramState diagram
State diagram
 
Domain State model OOAD
Domain State model  OOADDomain State model  OOAD
Domain State model OOAD
 
State Diagram
State DiagramState Diagram
State Diagram
 
Object Modeling Techniques
Object Modeling TechniquesObject Modeling Techniques
Object Modeling Techniques
 
State diagram railway reservation system
State diagram railway reservation systemState diagram railway reservation system
State diagram railway reservation system
 
Object Oriented Modeling and Design with UML
Object Oriented Modeling and Design with UMLObject Oriented Modeling and Design with UML
Object Oriented Modeling and Design with UML
 
Object Oriented Analysis and Design
Object Oriented Analysis and DesignObject Oriented Analysis and Design
Object Oriented Analysis and Design
 
Bab 10 state diagram 2010
Bab 10 state diagram 2010Bab 10 state diagram 2010
Bab 10 state diagram 2010
 
Beyond cons12
Beyond cons12Beyond cons12
Beyond cons12
 
Chapter 6 the modeling activity
Chapter 6   the modeling activityChapter 6   the modeling activity
Chapter 6 the modeling activity
 
behavioral model (DFD & state diagram)
behavioral model (DFD & state diagram)behavioral model (DFD & state diagram)
behavioral model (DFD & state diagram)
 
Online examination system for sanothimi campus purshuram
Online examination system for sanothimi campus purshuramOnline examination system for sanothimi campus purshuram
Online examination system for sanothimi campus purshuram
 
Object modeling
Object modelingObject modeling
Object modeling
 
03 fsm how_toimplementai_state_20161006_jintaeks
03 fsm how_toimplementai_state_20161006_jintaeks03 fsm how_toimplementai_state_20161006_jintaeks
03 fsm how_toimplementai_state_20161006_jintaeks
 
Ch02 3133
Ch02 3133Ch02 3133
Ch02 3133
 
Automatic Question Paper Generator
Automatic Question Paper GeneratorAutomatic Question Paper Generator
Automatic Question Paper Generator
 
Online Examination System Report
Online Examination System ReportOnline Examination System Report
Online Examination System Report
 
E r diagram
E r diagramE r diagram
E r diagram
 
Umar Erd
Umar ErdUmar Erd
Umar Erd
 

Similar to state modeling In UML

State modeling
State modelingState modeling
State modeling
Yashodha Sambrani
 
State Diagram.pdf
State Diagram.pdfState Diagram.pdf
State Diagram.pdf
ssuser226e3e
 
Software Engineering :Behavioral Modelling - II State diagram
Software Engineering :Behavioral Modelling - II State diagramSoftware Engineering :Behavioral Modelling - II State diagram
Software Engineering :Behavioral Modelling - II State diagram
Ajit Nayak
 
Diagrams
DiagramsDiagrams
Diagrams
janessa24
 
STATE DIAGRAM.pptx
STATE DIAGRAM.pptxSTATE DIAGRAM.pptx
STATE DIAGRAM.pptx
ssuser2d043c
 
States machine
States machineStates machine
States machine
Satyamevjayte Haxor
 
Java
Java   Java
Free ebooks download ! Edhole
Free ebooks download ! EdholeFree ebooks download ! Edhole
Free ebooks download ! Edhole
Edhole.com
 
Free ebooks download ! Edhole
Free ebooks download ! EdholeFree ebooks download ! Edhole
Free ebooks download ! Edhole
Edhole.com
 
Lecture08
Lecture08Lecture08
Lecture08
artgreen
 
Modeling behaviour via UML state machines [Software Design] [Computer Science...
Modeling behaviour via UML state machines [Software Design] [Computer Science...Modeling behaviour via UML state machines [Software Design] [Computer Science...
Modeling behaviour via UML state machines [Software Design] [Computer Science...
Ivano Malavolta
 
Programming models for event controlled programs
Programming models for event controlled programsProgramming models for event controlled programs
Programming models for event controlled programs
Priya Kaushal
 
08 state diagram and activity diagram
08 state diagram and activity diagram08 state diagram and activity diagram
08 state diagram and activity diagram
Baskarkncet
 
Seminar State Chart1
Seminar State Chart1Seminar State Chart1
Seminar State Chart1
Jenish Bhavsar
 
Software engineering.pptx
Software engineering.pptxSoftware engineering.pptx
Software engineering.pptx
NourhanTarek23
 
Software engineering.pptx
Software engineering.pptxSoftware engineering.pptx
Software engineering.pptx
NourhanTarek23
 
Modeling behaviour via UML state machines [Software Modeling] [Computer Scie...
Modeling behaviour via  UML state machines [Software Modeling] [Computer Scie...Modeling behaviour via  UML state machines [Software Modeling] [Computer Scie...
Modeling behaviour via UML state machines [Software Modeling] [Computer Scie...
Ivano Malavolta
 
Objec oriented Analysis and design Pattern
Objec oriented Analysis and design PatternObjec oriented Analysis and design Pattern
Objec oriented Analysis and design Pattern
Ashish Kumar Thakur
 
State diagram
State diagramState diagram
State diagram
Hareem Naz
 
State diagram
State diagramState diagram
State diagram
Hareem Naz
 

Similar to state modeling In UML (20)

State modeling
State modelingState modeling
State modeling
 
State Diagram.pdf
State Diagram.pdfState Diagram.pdf
State Diagram.pdf
 
Software Engineering :Behavioral Modelling - II State diagram
Software Engineering :Behavioral Modelling - II State diagramSoftware Engineering :Behavioral Modelling - II State diagram
Software Engineering :Behavioral Modelling - II State diagram
 
Diagrams
DiagramsDiagrams
Diagrams
 
STATE DIAGRAM.pptx
STATE DIAGRAM.pptxSTATE DIAGRAM.pptx
STATE DIAGRAM.pptx
 
States machine
States machineStates machine
States machine
 
Java
Java   Java
Java
 
Free ebooks download ! Edhole
Free ebooks download ! EdholeFree ebooks download ! Edhole
Free ebooks download ! Edhole
 
Free ebooks download ! Edhole
Free ebooks download ! EdholeFree ebooks download ! Edhole
Free ebooks download ! Edhole
 
Lecture08
Lecture08Lecture08
Lecture08
 
Modeling behaviour via UML state machines [Software Design] [Computer Science...
Modeling behaviour via UML state machines [Software Design] [Computer Science...Modeling behaviour via UML state machines [Software Design] [Computer Science...
Modeling behaviour via UML state machines [Software Design] [Computer Science...
 
Programming models for event controlled programs
Programming models for event controlled programsProgramming models for event controlled programs
Programming models for event controlled programs
 
08 state diagram and activity diagram
08 state diagram and activity diagram08 state diagram and activity diagram
08 state diagram and activity diagram
 
Seminar State Chart1
Seminar State Chart1Seminar State Chart1
Seminar State Chart1
 
Software engineering.pptx
Software engineering.pptxSoftware engineering.pptx
Software engineering.pptx
 
Software engineering.pptx
Software engineering.pptxSoftware engineering.pptx
Software engineering.pptx
 
Modeling behaviour via UML state machines [Software Modeling] [Computer Scie...
Modeling behaviour via  UML state machines [Software Modeling] [Computer Scie...Modeling behaviour via  UML state machines [Software Modeling] [Computer Scie...
Modeling behaviour via UML state machines [Software Modeling] [Computer Scie...
 
Objec oriented Analysis and design Pattern
Objec oriented Analysis and design PatternObjec oriented Analysis and design Pattern
Objec oriented Analysis and design Pattern
 
State diagram
State diagramState diagram
State diagram
 
State diagram
State diagramState diagram
State diagram
 

More from Kumar

Graphics devices
Graphics devicesGraphics devices
Graphics devices
Kumar
 
Fill area algorithms
Fill area algorithmsFill area algorithms
Fill area algorithms
Kumar
 
region-filling
region-fillingregion-filling
region-filling
Kumar
 
Bresenham derivation
Bresenham derivationBresenham derivation
Bresenham derivation
Kumar
 
Bresenham circles and polygons derication
Bresenham circles and polygons dericationBresenham circles and polygons derication
Bresenham circles and polygons derication
Kumar
 
Introductionto xslt
Introductionto xsltIntroductionto xslt
Introductionto xslt
Kumar
 
Extracting data from xml
Extracting data from xmlExtracting data from xml
Extracting data from xml
Kumar
 
Xml basics
Xml basicsXml basics
Xml basics
Kumar
 
XML Schema
XML SchemaXML Schema
XML Schema
Kumar
 
Publishing xml
Publishing xmlPublishing xml
Publishing xml
Kumar
 
DTD
DTDDTD
DTD
Kumar
 
Applying xml
Applying xmlApplying xml
Applying xml
Kumar
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
Kumar
 
How to deploy a j2ee application
How to deploy a j2ee applicationHow to deploy a j2ee application
How to deploy a j2ee application
Kumar
 
JNDI, JMS, JPA, XML
JNDI, JMS, JPA, XMLJNDI, JMS, JPA, XML
JNDI, JMS, JPA, XML
Kumar
 
EJB Fundmentals
EJB FundmentalsEJB Fundmentals
EJB Fundmentals
Kumar
 
JSP and struts programming
JSP and struts programmingJSP and struts programming
JSP and struts programming
Kumar
 
java servlet and servlet programming
java servlet and servlet programmingjava servlet and servlet programming
java servlet and servlet programming
Kumar
 
Introduction to JDBC and JDBC Drivers
Introduction to JDBC and JDBC DriversIntroduction to JDBC and JDBC Drivers
Introduction to JDBC and JDBC Drivers
Kumar
 
Introduction to J2EE
Introduction to J2EEIntroduction to J2EE
Introduction to J2EE
Kumar
 

More from Kumar (20)

Graphics devices
Graphics devicesGraphics devices
Graphics devices
 
Fill area algorithms
Fill area algorithmsFill area algorithms
Fill area algorithms
 
region-filling
region-fillingregion-filling
region-filling
 
Bresenham derivation
Bresenham derivationBresenham derivation
Bresenham derivation
 
Bresenham circles and polygons derication
Bresenham circles and polygons dericationBresenham circles and polygons derication
Bresenham circles and polygons derication
 
Introductionto xslt
Introductionto xsltIntroductionto xslt
Introductionto xslt
 
Extracting data from xml
Extracting data from xmlExtracting data from xml
Extracting data from xml
 
Xml basics
Xml basicsXml basics
Xml basics
 
XML Schema
XML SchemaXML Schema
XML Schema
 
Publishing xml
Publishing xmlPublishing xml
Publishing xml
 
DTD
DTDDTD
DTD
 
Applying xml
Applying xmlApplying xml
Applying xml
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
How to deploy a j2ee application
How to deploy a j2ee applicationHow to deploy a j2ee application
How to deploy a j2ee application
 
JNDI, JMS, JPA, XML
JNDI, JMS, JPA, XMLJNDI, JMS, JPA, XML
JNDI, JMS, JPA, XML
 
EJB Fundmentals
EJB FundmentalsEJB Fundmentals
EJB Fundmentals
 
JSP and struts programming
JSP and struts programmingJSP and struts programming
JSP and struts programming
 
java servlet and servlet programming
java servlet and servlet programmingjava servlet and servlet programming
java servlet and servlet programming
 
Introduction to JDBC and JDBC Drivers
Introduction to JDBC and JDBC DriversIntroduction to JDBC and JDBC Drivers
Introduction to JDBC and JDBC Drivers
 
Introduction to J2EE
Introduction to J2EEIntroduction to J2EE
Introduction to J2EE
 

Recently uploaded

AI Based Testing - A Comprehensive Guide.pdf
AI Based Testing - A Comprehensive Guide.pdfAI Based Testing - A Comprehensive Guide.pdf
AI Based Testing - A Comprehensive Guide.pdf
kalichargn70th171
 
Building API data products on top of your real-time data infrastructure
Building API data products on top of your real-time data infrastructureBuilding API data products on top of your real-time data infrastructure
Building API data products on top of your real-time data infrastructure
confluent
 
Solar Panel Service Provider annual maintenance contract.pdf
Solar Panel Service Provider annual maintenance contract.pdfSolar Panel Service Provider annual maintenance contract.pdf
Solar Panel Service Provider annual maintenance contract.pdf
SERVE WELL CRM NASHIK
 
Hi-Fi Call Girls In Hyderabad 💯Call Us 🔝 7426014248 🔝Independent Hyderabad Es...
Hi-Fi Call Girls In Hyderabad 💯Call Us 🔝 7426014248 🔝Independent Hyderabad Es...Hi-Fi Call Girls In Hyderabad 💯Call Us 🔝 7426014248 🔝Independent Hyderabad Es...
Hi-Fi Call Girls In Hyderabad 💯Call Us 🔝 7426014248 🔝Independent Hyderabad Es...
sapnasaifi408
 
🔥 Chennai Call Girls  👉 6350257716 👫 High Profile Call Girls Whatsapp Number ...
🔥 Chennai Call Girls  👉 6350257716 👫 High Profile Call Girls Whatsapp Number ...🔥 Chennai Call Girls  👉 6350257716 👫 High Profile Call Girls Whatsapp Number ...
🔥 Chennai Call Girls  👉 6350257716 👫 High Profile Call Girls Whatsapp Number ...
tinakumariji156
 
Call Girls Bangalore🔥7023059433🔥Best Profile Escorts in Bangalore Available 24/7
Call Girls Bangalore🔥7023059433🔥Best Profile Escorts in Bangalore Available 24/7Call Girls Bangalore🔥7023059433🔥Best Profile Escorts in Bangalore Available 24/7
Call Girls Bangalore🔥7023059433🔥Best Profile Escorts in Bangalore Available 24/7
manji sharman06
 
Folding Cheat Sheet #6 - sixth in a series
Folding Cheat Sheet #6 - sixth in a seriesFolding Cheat Sheet #6 - sixth in a series
Folding Cheat Sheet #6 - sixth in a series
Philip Schwarz
 
Call Girls in Varanasi || 7426014248 || Quick Booking at Affordable Price
Call Girls in Varanasi || 7426014248 || Quick Booking at Affordable PriceCall Girls in Varanasi || 7426014248 || Quick Booking at Affordable Price
Call Girls in Varanasi || 7426014248 || Quick Booking at Affordable Price
vickythakur209464
 
🔥 Kolkata Call Girls  👉 9079923931 👫 High Profile Call Girls Whatsapp Number ...
🔥 Kolkata Call Girls  👉 9079923931 👫 High Profile Call Girls Whatsapp Number ...🔥 Kolkata Call Girls  👉 9079923931 👫 High Profile Call Girls Whatsapp Number ...
🔥 Kolkata Call Girls  👉 9079923931 👫 High Profile Call Girls Whatsapp Number ...
tinakumariji156
 
Accelerate your Sitecore development with GenAI
Accelerate your Sitecore development with GenAIAccelerate your Sitecore development with GenAI
Accelerate your Sitecore development with GenAI
Ahmed Okour
 
Erotic Call Girls Bangalore🫱9079923931🫲 High Quality Call Girl Service Right ...
Erotic Call Girls Bangalore🫱9079923931🫲 High Quality Call Girl Service Right ...Erotic Call Girls Bangalore🫱9079923931🫲 High Quality Call Girl Service Right ...
Erotic Call Girls Bangalore🫱9079923931🫲 High Quality Call Girl Service Right ...
meenusingh4354543
 
Strengthening Web Development with CommandBox 6: Seamless Transition and Scal...
Strengthening Web Development with CommandBox 6: Seamless Transition and Scal...Strengthening Web Development with CommandBox 6: Seamless Transition and Scal...
Strengthening Web Development with CommandBox 6: Seamless Transition and Scal...
Ortus Solutions, Corp
 
Call Girls Goa 💯Call Us 🔝 7426014248 🔝 Independent Goa Escorts Service Available
Call Girls Goa 💯Call Us 🔝 7426014248 🔝 Independent Goa Escorts Service AvailableCall Girls Goa 💯Call Us 🔝 7426014248 🔝 Independent Goa Escorts Service Available
Call Girls Goa 💯Call Us 🔝 7426014248 🔝 Independent Goa Escorts Service Available
sapnaanpad7
 
Trailhead Talks_ Journey of an All-Star Ranger .pptx
Trailhead Talks_ Journey of an All-Star Ranger .pptxTrailhead Talks_ Journey of an All-Star Ranger .pptx
Trailhead Talks_ Journey of an All-Star Ranger .pptx
ImtiazBinMohiuddin
 
Streamlining End-to-End Testing Automation
Streamlining End-to-End Testing AutomationStreamlining End-to-End Testing Automation
Streamlining End-to-End Testing Automation
Anand Bagmar
 
119321250-History-of-Computer-Programming.ppt
119321250-History-of-Computer-Programming.ppt119321250-History-of-Computer-Programming.ppt
119321250-History-of-Computer-Programming.ppt
lavesingh522
 
What’s New in VictoriaLogs - Q2 2024 Update
What’s New in VictoriaLogs - Q2 2024 UpdateWhat’s New in VictoriaLogs - Q2 2024 Update
What’s New in VictoriaLogs - Q2 2024 Update
VictoriaMetrics
 
Folding Cheat Sheet #5 - fifth in a series
Folding Cheat Sheet #5 - fifth in a seriesFolding Cheat Sheet #5 - fifth in a series
Folding Cheat Sheet #5 - fifth in a series
Philip Schwarz
 
Secure-by-Design Using Hardware and Software Protection for FDA Compliance
Secure-by-Design Using Hardware and Software Protection for FDA ComplianceSecure-by-Design Using Hardware and Software Protection for FDA Compliance
Secure-by-Design Using Hardware and Software Protection for FDA Compliance
ICS
 

Recently uploaded (20)

AI Based Testing - A Comprehensive Guide.pdf
AI Based Testing - A Comprehensive Guide.pdfAI Based Testing - A Comprehensive Guide.pdf
AI Based Testing - A Comprehensive Guide.pdf
 
Building API data products on top of your real-time data infrastructure
Building API data products on top of your real-time data infrastructureBuilding API data products on top of your real-time data infrastructure
Building API data products on top of your real-time data infrastructure
 
Solar Panel Service Provider annual maintenance contract.pdf
Solar Panel Service Provider annual maintenance contract.pdfSolar Panel Service Provider annual maintenance contract.pdf
Solar Panel Service Provider annual maintenance contract.pdf
 
Hi-Fi Call Girls In Hyderabad 💯Call Us 🔝 7426014248 🔝Independent Hyderabad Es...
Hi-Fi Call Girls In Hyderabad 💯Call Us 🔝 7426014248 🔝Independent Hyderabad Es...Hi-Fi Call Girls In Hyderabad 💯Call Us 🔝 7426014248 🔝Independent Hyderabad Es...
Hi-Fi Call Girls In Hyderabad 💯Call Us 🔝 7426014248 🔝Independent Hyderabad Es...
 
🔥 Chennai Call Girls  👉 6350257716 👫 High Profile Call Girls Whatsapp Number ...
🔥 Chennai Call Girls  👉 6350257716 👫 High Profile Call Girls Whatsapp Number ...🔥 Chennai Call Girls  👉 6350257716 👫 High Profile Call Girls Whatsapp Number ...
🔥 Chennai Call Girls  👉 6350257716 👫 High Profile Call Girls Whatsapp Number ...
 
Call Girls Bangalore🔥7023059433🔥Best Profile Escorts in Bangalore Available 24/7
Call Girls Bangalore🔥7023059433🔥Best Profile Escorts in Bangalore Available 24/7Call Girls Bangalore🔥7023059433🔥Best Profile Escorts in Bangalore Available 24/7
Call Girls Bangalore🔥7023059433🔥Best Profile Escorts in Bangalore Available 24/7
 
Folding Cheat Sheet #6 - sixth in a series
Folding Cheat Sheet #6 - sixth in a seriesFolding Cheat Sheet #6 - sixth in a series
Folding Cheat Sheet #6 - sixth in a series
 
Call Girls in Varanasi || 7426014248 || Quick Booking at Affordable Price
Call Girls in Varanasi || 7426014248 || Quick Booking at Affordable PriceCall Girls in Varanasi || 7426014248 || Quick Booking at Affordable Price
Call Girls in Varanasi || 7426014248 || Quick Booking at Affordable Price
 
🔥 Kolkata Call Girls  👉 9079923931 👫 High Profile Call Girls Whatsapp Number ...
🔥 Kolkata Call Girls  👉 9079923931 👫 High Profile Call Girls Whatsapp Number ...🔥 Kolkata Call Girls  👉 9079923931 👫 High Profile Call Girls Whatsapp Number ...
🔥 Kolkata Call Girls  👉 9079923931 👫 High Profile Call Girls Whatsapp Number ...
 
bgiolcb
bgiolcbbgiolcb
bgiolcb
 
Accelerate your Sitecore development with GenAI
Accelerate your Sitecore development with GenAIAccelerate your Sitecore development with GenAI
Accelerate your Sitecore development with GenAI
 
Erotic Call Girls Bangalore🫱9079923931🫲 High Quality Call Girl Service Right ...
Erotic Call Girls Bangalore🫱9079923931🫲 High Quality Call Girl Service Right ...Erotic Call Girls Bangalore🫱9079923931🫲 High Quality Call Girl Service Right ...
Erotic Call Girls Bangalore🫱9079923931🫲 High Quality Call Girl Service Right ...
 
Strengthening Web Development with CommandBox 6: Seamless Transition and Scal...
Strengthening Web Development with CommandBox 6: Seamless Transition and Scal...Strengthening Web Development with CommandBox 6: Seamless Transition and Scal...
Strengthening Web Development with CommandBox 6: Seamless Transition and Scal...
 
Call Girls Goa 💯Call Us 🔝 7426014248 🔝 Independent Goa Escorts Service Available
Call Girls Goa 💯Call Us 🔝 7426014248 🔝 Independent Goa Escorts Service AvailableCall Girls Goa 💯Call Us 🔝 7426014248 🔝 Independent Goa Escorts Service Available
Call Girls Goa 💯Call Us 🔝 7426014248 🔝 Independent Goa Escorts Service Available
 
Trailhead Talks_ Journey of an All-Star Ranger .pptx
Trailhead Talks_ Journey of an All-Star Ranger .pptxTrailhead Talks_ Journey of an All-Star Ranger .pptx
Trailhead Talks_ Journey of an All-Star Ranger .pptx
 
Streamlining End-to-End Testing Automation
Streamlining End-to-End Testing AutomationStreamlining End-to-End Testing Automation
Streamlining End-to-End Testing Automation
 
119321250-History-of-Computer-Programming.ppt
119321250-History-of-Computer-Programming.ppt119321250-History-of-Computer-Programming.ppt
119321250-History-of-Computer-Programming.ppt
 
What’s New in VictoriaLogs - Q2 2024 Update
What’s New in VictoriaLogs - Q2 2024 UpdateWhat’s New in VictoriaLogs - Q2 2024 Update
What’s New in VictoriaLogs - Q2 2024 Update
 
Folding Cheat Sheet #5 - fifth in a series
Folding Cheat Sheet #5 - fifth in a seriesFolding Cheat Sheet #5 - fifth in a series
Folding Cheat Sheet #5 - fifth in a series
 
Secure-by-Design Using Hardware and Software Protection for FDA Compliance
Secure-by-Design Using Hardware and Software Protection for FDA ComplianceSecure-by-Design Using Hardware and Software Protection for FDA Compliance
Secure-by-Design Using Hardware and Software Protection for FDA Compliance
 

state modeling In UML

  • 2. Introduction • The structure of objects and their relationships to each other in a system described by its static structure i.e. the class model. • Some objects in a system have complex temporal behaviors, which must be carefully design. • Temporal phenomena that occur over an interval of time are properly modeled with a state • The state model examine changes to the objects and their relationships over time • The state model describes the sequence of operations that occur in response to events (external stimuli)
  • 3. Events • occurrence at a point in time – instantaneous – often corresponds to verb in past tense • e.g., alarm set, powered on – or onset of a condition • e.g., paper tray becomes empty, temperature drops below freezing • may logically precede or follow another or may be unrelated – e.g., Flight 123 must depart DDN before it can arrive in Delhi (causally related) – e.g., Flight 123 may depart before or after flight 345 departs DDN (causally unrelated) • Concurrent event: causally unrelated events; have no effect on one another
  • 4. Kinds of events Signal event: – the event of sending or receiving of a signal • Signal: an explicit one-way transmission of information from one object to another • may be parameterized – E.g., stringEntered(“Foo”) – sending of a signal by one object is a distinct event from its reception by another – Difference between signal and signal event – every signal transmission is a unique occurrence but we group them into signal classes to indicate common structure and behavior. • E.g., IA flight 123 departs from DDN on Jan 11, 2013 is an instance of FlightDeparture
  • 5. Signal class - UML notation << signal >> FlightDeparture airline flightNum city date keyword “signal” in << >> name of signal class attributes
  • 6. Kinds of Events • Change event – Event caused by satisfaction of a Boolean expression – Intent: Expression continually tested; when changes from false to true, the event happens – UML Notation: keyword when followed by parenthesized boolean expression • when(room temperature < heating set point) • when(room temperature > cooling set point) • when(battery power < lower limit) • when(tire pressure < minimum pressure)
  • 7. Kinds of Events • Time event – Event caused by the occurrence of an absolute time or the elapse of a time interval – for absolute time the UML Notation: keyword when followed by parenthesized expression involving time • when (date = Jan 1, 2013) – for time interval the UML Notation: keyword after followed by parenthesized expression that evaluate to a time duration • after (n timeUnits) • after(10 seconds)
  • 8. States • an abstraction of values and links of an object • behavioral condition that persists in time • according to gross behavior of objects, set of values and links are grouped together into a state • often corresponds to – verbs with suffix of “-ing” • e.g., Boiling, Waiting, Dialing – the duration of some condition • e.g., Powered, BelowFreezing • UML Notation: a rounded box containing an optional state name Powered Waiting Dialing
  • 9. Contd. • In defining states – ignore attributes that do not affect the behavior of the object – lump together in a single state all combinations of values and links with the same response to events – E.g., except for leading 0’s & 1’s, the exact digits dialed do not affect the control of the phone line, so we can define a state Dialing and track the phone number as a parameter • Objects in a class have a finite number of possible states – Each object can only be in one state at a time – At a given moment of time, the various objects for a class can exist in a multitude of states • A state specifies the response of an object to input events – E.g., if a digit is dialed in state DialTone, the phone line drops the dial tone and enters state Dialing; – If the receiver is replaced in state DialTone, the phone line goes dead and enters state Idle.
  • 10. Symmetry between Events and States • Events represent points in time • State represent intervals of time. A state corresponds to the interval between two events received by an object Power turned on Power turned off Power turned on Powered Not Powered
  • 11. Transitions and Conditions • Transition: an instantaneous change in state – triggered by an event – Transition is said to fire upon the change from source to target state – Origin and target state of a transition are different states but may be the same – e.g., when a phone line is answered, the phone line transitions from the Ringing state to the Connected state. • Guard Condition: – boolean expression that must be true for transition to occur – checked only once, at the time event occurs; transition fires if true – E.g., when you go out in the morning (event), if the temperature is below freezing (condition), then put on your gloves (next state).
  • 12. Enabling and firing of transitions Transition is: – enabled when source state is active and guard condition satisfied – fires when enabled and the triggering event occurs Example below: – enabled when current state is Editing and the form is complete – fires when the user presses the “OK” button Editing Submitted pressOK [form complete]
  • 13. State Diagrams • a graph whose nodes are states and whose directed arcs are transitions between states • specifies state sequences caused by event sequences • all objects in a class execute the state diagram for that class; diagram models their common behavior – Note: state names are unique within the scope of state diagram – A class with more than one state has important temporal behavior – A class is temporarily important if it has a single state with multiple responses to events
  • 14. State diagrams Graphical state-modeling notation: – States: labeled rounded box – Transitions: directed arcs, labeled by triggering event, optional guard condition, and/or effects Specifies the response of an object to input events - ignores events except those for which behavior is prescribed Example: S T States
  • 15. State diagrams S T States Transition Graphical state-modeling notation: – States: labeled rounded box – Transitions: directed arcs, labeled by triggering event, optional guard condition, and/or effects Specifies the response of an object to input events - ignores events except those for which behavior is prescribed Example:
  • 16. State diagrams Graphical state-modeling notation: – States: labeled rounded box – Transitions: directed arcs, labeled by triggering event, optional guard condition, and/or effects Example: S T event(attribs) [condition] / effect States EventTransition
  • 17. • State diagrams can represent – Continuous loops • Do not care, how the loop is started – One-shot life cycles
  • 19. “One-shot” state diagrams • represent objects with finite lives – have initial and finite states • initial state - entered on object creation • final state - entry implies destruction of object
  • 22. Example - entry and exit points White’s turn Black’s turn white moves black moves checkmate checkmate stalemate stalemate Chess game Black wins Draw White wins
  • 23. State Model • multiple state diagrams, one for each class with important temporal behavior – diagrams interact by passing events and through side effects of guard conditions – events and guard conditions must match across diagrams in the model
  • 24. Details – if more than one transition leaves a state, then the first event to occur causes the corresponding transition to fire – if an event occurs and no transition matches it, the event is ignored – if more than one transition matches an event, only one transition will fire but the choice is non- deterministic
  • 25. Activity Effects • effect = reference to a behavior executed in response to an event – can be attached to a transition or a state – listed after a slash (“/”) – multiple effects separated with a “,” and are performed concurrently
  • 26. Activity Effects • Activity = behavior that can be invoked by any number of effects • May be performed upon: – a transition – entry to or exit from a state – some event within a state • Notation: – event / resulting-activity
  • 27. Activities Often useful to specify an activity that is performed within a given state – E.g., while in PaperJam state, the warning light should be flashing – E.g., on entry into the Opening state, the motor should be switched on – E.g., upon exit of the Opening state, the motor should be switched off
  • 28. Activity effects Idle Menu visible r_button_down / showPopup r_button_up / hidePopup
  • 29. Do-Activities PaperJam do/ flash warning light • continue for an extended time • can occur only within a state • can not be attached to a transition • include • continuous operations, such as displaying a picture on a television screen • Sequential operations that terminate by themselves after an interval of time • may be performed for all or part of time that an object is in a state • may be interrupted by event received during execution; event may or may not cause state transition
  • 30. Entry and Exit Activities Opening entry / motor up exit / motor off • can bind activities to entry to/ exit from a state •All transitions into a state perform the same activity, in which case it is more concise to attach the activity to the state
  • 31. Order of activities 1. activities on incoming transition 2. entry activities 3. do-activities 4. exit activities 5. activities on outgoing transition Events that cause transitions out of the state can interrupt do-activities. If a do-activity is interrupted, the exit activity is still performed
  • 32. • In general, any event can occur within a state and cause an activity to be performed. • Entry and exit are only two examples of events that can occur • Difference between an event within a state and self-transition: only the self-transition causes the entry and exit activities to be executed but an event within a state does not
  • 33. Completion Transition • triggered by completion of activity in the source state • Often the sole purpose of a state is to perform a sequential activity. • When the activity is completed, a transition to another state fires • An arrow without an event name indicates an automatic transition that fires State 1 do / blah() State 2
  • 34. Contd. • If a state has one or more completion transitions, but none of the guard conditions are satisfied, then the state remains active and may become ‘stuck’. • The completion event does not occur a second time • Therefore no completion transition will fire later to change the state • So if a state has completion transition leaving it, normally guard condition should cover every possible outcome. • Do not use guard condition on a completion transition to model waiting for a change of value
  • 35. Sending signals • A object can perform the activity of sending a signal to another object. • A system of objects interact by exchanging signals • The activity “send target.S(attributes)” sends a signal S with the given attributes to the target object. • E.g., the phone line sends a connect(phone number) signal to the switcher when a complete phone number has been dialed. • A signal can be directed to a set of objects or a single object. • If the target is a set of objects, each of them receives a separate copy of the signal concurrently and independently process the signal and determines whether to fire a transition or not • If an object receive signals from more than one object, the order in which concurrent signals are received may affect the final state (race condition)
  • 36. Advanced state modeling • Conventional state diagrams are sufficient for describing simple systems but need additional power to handle large problems • Model complex system by using – Nested state diagrams – Nested states – Signal generalization – Concurrency
  • 37. Nested state diagram • Problem with flat state diagram – Consider an object with n independent Boolean attributes that affect control – representing such object with a single flat state diagram would require 2n states • Expanding state – Organize the model by having high-level diagram with sub diagrams expanding certain states – Submachine: a state diagram that may be invoked as part of another state diagram (lower-level state diagram). – UML Notation for submachine: list a local name followed by a colon and the submachine name.
  • 38. Nested state • Nest states to show their commonality and share behavior • Composite state: state that encloses the nested states. – Labels in the outer contour • A nested state receives the outgoing transitions of its composite states
  • 39. Example: Transmission Transmission Forward Neutral Reverse 1st 2nd 3rd downshift upshift downshift upshift stop push N push F push N push R
  • 40. Signal Generalization • Organize signals into generalization hierarchy with inheritance of signal attributes • View every actual signal as a leaf on a generalization tree of signals. • Received signal triggers transitions that are defined for any ancestor signal type. – E.g., typing an ‘a’ would trigger a transition on signal Alphanumeric as well as signal KeyboardCharacter. • A signal hierarchy permits different levels of abstraction to be used in a model. – E.g., some state might handle all i/p characters the same; other states might treat control characters differently from printing characters .
  • 41. CONCURRENCY • State model supports concurrency among objects • Object can act & change state independent of one another. • Sometime objects shares constraints that causes their state changes
  • 42. AGGREGATION CONCURRENCY • State Aggregation means collection of state diagrams , one for each part • “and” relationship • Aggregate state is one state from first diagram & a state from second diagram & state from each other diagram. • Transition for one object depend on another object that allows interaction between the state diagram.
  • 43.
  • 44. Concurrency within an Object • Some objects can be partitioned into subsets of attributes or links. • Each of the partitioned subset has its own subdiagram. • The state of the object comprises one state from each subdiagram. • The sub diagrams need not be independent; the same event can cause transitions in more than one subdiagram • UML Notation- partition the composite state into regions with dotted lines.
  • 45. Synchronization of Concurrent Activities • Sometimes one object must perform two ( or more) activities concurrently. • The object must complete both activities before it can progress to its next state.
  • 46. Fork and Join OR Splitting control and Merging control • FORK- A transition that forks indicates splitting of control into concurrent parts. • JOIN- Explicit merging of concurrent control by a transition.
  • 47. Relation of class model, state model • A state diagram describes all or part of the behavior of the objects of a given class. • States = classes of values & link for an object • State model of a class is inherited by its subclasses. Subclass inherits both the state & Transitions. • It is also possible to refine an inherited state diagram by expanding state into nested state or concurrent sub diagrams.
  • 48. Contd. • State structure is related to and constrained by class structure. – A composite state is the aggregation of more than one concurrent substate. – Try to make the state diagrams of subclasses independent of the state diagrams of their superclasses.
  翻译: