210 likes | 343 Views
CS451 Introduction to Software Engineering. Behavioral Modeling. Behavioral Modeling. events. behavior. Outside world. Application. Behavioral Modeling. M ake a list of the different states of a system (How does the system behave?)
E N D
CS451 Introduction to Software Engineering Behavioral Modeling
Behavioral Modeling events behavior Outside world Application
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 state event causing transition action that occurs new state
State Transition Diagram full and start reading invoke manage-copying operator commands full invoke read-op-input copies done invoke read-op-input making copies reloading paper empty invoke reload paper jammed invoke problem-diagnosis not jammed invoke read-op-input problem state
Control Model • The control flow diagram is "superimposed" on the DFD and shows events that control the processes noted in the DFD • Control flows • Events and control items—by dashed arrows • A vertical bar implies an input to or output from a control spec (CSPEC) — a separate specification that describes how control is handled • A dashed arrow entering a vertical bar is an input to the CSPEC • A dashed arrow leaving a process implies a data condition • A dashed arrow entering a process implies a control input read directly by the process • Control flows do not physically activate/deactivate the processes—this is done via the CSPEC
UML: Behavioral modeling • Activity Diagrams • Statechart Diagrams • Interaction Diagrams
deposit Over drafted withdraw withdraw deposit ok UML: State Diagram • Shows the behavior of one object • How 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
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 state variable(s) entry: entry action do: activity-A on: event-A: action-A exit: exit-action
Transition notation (2) Event(arguments)[condition]/action State-A State-B • 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
Event(attribute) State-B Initial state 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
State transitions for an order get next item[ not all Item received[ some items checked ] items not in stock ] [ All items checked && some items not in stock ] / get first item Checking Waiting do: check item [ All items checked && Item received[ all items all items available ] available ] Dispatching Delivered Delivered do: initiate delivery
Example: Payment authorization in class Order 2 parallel processes: - authorization - order handling Authorizing [ payment not ok ] do: check payment [ payment ok ] Rejected Authorized Delivered
Concurrent state diagram for the class Order Cancelled Waiting Waiting Dispatching Dispatching Checking Checking Delivered Authorizing Authorizing Authorized Authorized 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
Microwave oven state description State Description Waiting The oven is waiting for input. The display shows the current time. Half power The oven power is set to 300 watts. The display shows ‘Half power’. Full power The oven power is set to 600 watts. The display shows ‘Full power’. Set time The cooking time is set to the user’s input value. The display shows the cooking time selected and is updated as the time is set. Disabled Oven operation is disabled for safety. Interior oven light 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. Display shows the timer countdown. On completion of cooking, the buzzer is sounded for 5 seconds. Oven light is on. Display shows ‘Cooking complete’ while buzzer 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 button Timer The user has pressed one of the timer buttons Number The user has pressed a numeric key Door open The oven door switch is not closed Door closed The oven door switch is closed Start The user has pressed the start button Cancel The user has pressed the cancel button