CS451 Introduction to Software Engineering Behavioral Modeling.
-
Upload
angelina-ward -
Category
Documents
-
view
217 -
download
0
Transcript of CS451 Introduction to Software Engineering Behavioral Modeling.
CS451 Introduction to Software Engineering
Behavioral Modeling
Behavioral Modeling
Outsideworld
Application
events behavior
Behavioral Modeling
• Make a list of the different states of a system (How does the system behave?)
• Indicate how the system makes a transition from one state to another (How does the system change state?)– indicate event– indicate action
• Draw a state transition diagram
The States of a System
• state—a set of observable circumstances that characterizes the behavior of a system at a given time
• state transition—the movement from one state to another
• event—an occurrence that causes the system to exhibit some predictable form of behavior
• action—process that occurs as a consequence of making a transition
State Transition Diagram Notation
statestate
new statenew state
event causing transitionevent causing transitionaction that occursaction that occurs
State Transition Diagram
readingreadingoperatoroperator
commandscommands
making copiesmaking copies reloading paperreloading paper
problem stateproblem state
fullfullinvoke read-op-inputinvoke read-op-input
full and startfull and startinvoke manage-copyinginvoke manage-copying
copies donecopies doneinvoke read-op-inputinvoke read-op-input
emptyemptyinvoke reload paperinvoke reload paper
jammedjammedinvoke problem-diagnosisinvoke problem-diagnosis
not jammednot jammedinvoke read-op-inputinvoke read-op-input
Control Model• TThe control flow diagram is "superimposed" on the DFD and he control flow diagram is "superimposed" on the DFD and
shows events that control the processes noted in the DFDshows events that control the processes noted in the DFD• CControl flowsontrol flows
– EEvents and control items—by dashed arrowsvents and control items—by dashed arrows– AA vertical bar implies an input to or output from a control vertical bar implies an input to or output from a control
spec (CSPEC) — a separate specification that describes spec (CSPEC) — a separate specification that describes how control is handledhow control is handled
– AA dashed arrow entering a vertical bar is an input to the dashed arrow entering a vertical bar is an input to the CSPECCSPEC
– AA dashed arrow leaving a process implies a data condition dashed arrow leaving a process implies a data condition– AA dashed arrow entering a process implies a control input dashed arrow entering a process implies a control input
read directly by the processread directly by the process• CControl flows do not physically activate/deactivate the ontrol flows do not physically activate/deactivate the
processes—this is done via the CSPECprocesses—this is done via the CSPEC
Control Flow Diagram
read operator
input manage copying
reload process
perform problem
diagnosis
create user
displays
empty
jammed
full
display panel enabled
beeper on/off
start
problem light
copies done
UML: Behavioral modeling
• Activity Diagrams
• Statechart Diagrams
• Interaction Diagrams
UML: State Diagram
Shows the behavior of one objectHow does it change its state based on the messages it receives, narrowly focused, fine-grained
• State: condition/situation during lifetime of an object • State transition: relationship indicating a state change (atomic & non interruptible)• Action: atomic & non-interruptible
Over drafted
ok
deposit
withdraw
deposit
withdraw
State notation (1)
• Substates: disjoint/concurrent• Entry/exit actions
– entry: an action that is performed on entry to the state
– exit: an action performed on exiting the state
• do: an ongoing activity performed while in the state (example: display window)– interruptible
• on: an action performed as a result of a specific event
State name
entry: entry action
exit: exit-action
do: activity-Aon: event-A: action-A
state variable(s)
State-A State-BEvent(arguments)[condition]/action
Transition notation (2)
• Event: significant occurrence that has a location in time and space– triggers the transition– signals, calls, passing of time, change in state
• Guard condition: • Transition only eligible to fire when guard evaluates to true• Guards of transition exiting one state are mutually exclusive
• Action: executable atomic computation
State diagram notation (3)
• Start state– No event triggers allowed – Branch conditions allowed– May not remain in start states
• End state– Top level end state terminates a state
machine
Initial state State-BEvent(attribute)
State transitions for an order
Checking
do: check item
Dispatching
do: initiate delivery
Waiting
Delivered
/ get first item
Item received[ some items not in stock ]
Item received[ all items available ]
Delivered
[ All items checked && some items not in stock ]
[ All items checked && all items available ]
get next item[ not all items checked ]
Example: Payment authorization in class Order
Authorizing
do: check payment
Authorized
Delivered
Rejected
[ payment ok ]
[ payment not ok ] 2 parallel processes:- authorization- order handling
Concurrent state diagram for the class Order
Checking
Waiting
Dispatching
Authorizing Authorized
Checking
Waiting
Dispatching
Authorizing Authorized
Cancelled
Delivered
Rejected
Statecharts
• Allow the decomposition of a model into sub-models
• A brief description of the actions is included following the ‘do’ in each state
• Can be complemented by tables describing the states and the stimuli
Full power
Enabled
do: operateoven
Fullpower
Halfpower
Halfpower
Fullpower
Number
TimerDooropen
Doorclosed
Doorclosed
Dooropen
Start
do: set power = 600
Half powerdo: set power = 300
Set time
do: get numberexit: set time
Disabled
Operation
Timer
Cancel
Waiting
do: display time
Waiting
do: display time
do: display 'Ready'
do: display 'Waiting'
Microwave Oven Model
Microwave oven state description
State Description
Waiting The oven is waiting for input. The display shows thecurrent time.
Half power The oven power is set to 300 watts. The displayshows ‘Half power’.
Full power The oven power is set to 600 watts. The displayshows ‘Full power’.
Set time The cooking time is set to the user’s input value. Thedisplay shows the cooking time selected and isupdated as the time is set.
Disabled Oven operation is disabled for safety. Interior ovenlight is on. Display shows ‘Not ready’.
Enabled Oven operation is enabled. Interior oven light is off.Display shows ‘Ready to cook’.
Operation Oven in operation. Interior oven light is on. Displayshows the timer countdown. On completion ofcooking, the buzzer is sounded for 5 seconds. Ovenlight is on. Display shows ‘Cooking complete’ whilebuzzer is sounding.
Microwave oven stimuli
Stimulus Description
Half power The user has pressed the half power button
Full power The user has pressed the full power buttonTimer The user has pressed one of the timer buttonsNumber The user has pressed a numeric keyDoor open The oven door switch is not closedDoor closed The oven door switch is closedStart The user has pressed the start buttonCancel The user has pressed the cancel button
Microwave oven operation
Cookdo: run generator
Done
do: buzzer on for 5 secs.
Waiting
Alarm
do: display event
do: checkstatus
Checking
Turntablefault
Emitterfault
Disabled
OK
Timeout
TimeOperation
Dooropen
Cancel