state machine statechart diagrams interaction diagrams – society of objects state machine –...

22
ADVANCED BEHAVIORAL MODELING

Upload: jasmine-ryan

Post on 22-Dec-2015

229 views

Category:

Documents


1 download

TRANSCRIPT

ADVANCED BEHAVIORAL MODELING

PLAN OF TALK

State Machine Statechart Diagrams

STATE MACHINES

Interaction Diagrams – Society of Objects State Machine – Individual object

It specifies life time of instances of class, use case or an entire system

Events corresponds to signal, operation or passing of time

Activity – nonatomic execution Action – executable atomic computation Visualization of State Machines

Activity Diagrams Statechart Diagrams

USAGE OF STATE MACHINES

When one object is acted on other object by a synchronous operation call, they do not need state machine to specify their behavior

They apply to objects that must respond to signals, which are asynchronous stimuli communicated between instances

Ultimately The behavior of objects that must respond to

asynchronous stimulus Or whose current behavior depends on their past is best

specified by using a state machine

TERMS

Usage – To model the behavior of use case, interface

State situation during the life of an object during which it

satisfies some condition, performs some activity, or waits for some event

Its Parts- Name entry/exit actions Internal Transitions Substates Deferred events

What are pseudostates?

TERMS

TERMS Transitions

relationship between two states On such a change of state, the transition is

said to fire from source state to target state

Parts Source

state Event

trigger Guard

condition Action Target state

TERMS

Advanced State and Transitions Entry actions- No matter which transition led you there Exit actions- No matter which transition led you away Internal transitions- the event is handled without

dispatching the state's exit and then entry actions. Activities- Ongoing work in state Deferred events-want to recognize some events but

postpone a response to them by queuing the events

STATE MACHINE

STUDENT

OBJECT

SUBSTATES

It is a state that's nested inside another one A state that has substates that is, nested states is

called a composite state. A nested sequential state machine may have at most

one initial state and one final state.

Validating and Processing are called sequential, or disjoint, substates.

SUBSTATES

Dialing a number on a telephone Line

HISTORY SUBSTATE

To remember the last substate that was active prior to leaving the composite state e.g. unattended backup of computers

H designates a shallow history, which remembers only the history of the immediate nested state machine.

deep history denoted as H* remembers the innermost nested state at any depth

If nested state machine reaches a final state, it loses its stored history

HISTORY SUBSTATE

CONCURRENT SUBSTATES

Allows to specify two or more state machines that execute in parallel in the context of the enclosing object

OR model concurrency is by using active objects Each Concurrent Substates further decomposed into

sequential substates

CONCURRENT SUBSTATES

STATECHART DIAGRAMS

A statechart diagram shows a state machine An activity diagram is a special case of a statechart

diagram in which all or most of the states are activity states and all or most of the transitions are triggered by completion of activities in the source state

Statechart Diagram shows flow of control from state to state

This involves modeling the behavior of reactive objects

Reactive object - is one whose behavior is best characterized by its response to events dispatched from outside its context

STATECHART DIAGRAMS

ELEMENTS OF STATECHART DIAGRAM Simple states Composite states Transitions including events and actions A statechart diagram may contain any

and all features of a state machine

TO MODEL REACTIVE OBJECT Choose the context for the state machine, whether it is

a class, a use case, or the system as a whole Choose the initial and final states for the object. To

guide the rest of your model, possibly state the pre- and postconditions of the initial and final states, respectively.

Decide on the stable states of the object by considering the conditions in which the object may exist for some identifiable period of time.

Decide on the meaningful partial ordering of stable states over the lifetime of the object

Decide on the events that may trigger a transition from state to state. Model these events as triggers to transitions that move from one legal ordering of states to another.

TO MODEL REACTIVE OBJECT Attach actions to these transitions (as in a Mealy

machine) and/or to these states (as in a Moore machine) Consider ways to simplify your machine by using

substates, branches, forks, joins, and history states. Check that all states are reachable under some combination of events

Check that no state is a dead end from which no combination of events will transition the object out of that state.

Trace through the state machine, either manually or by using tools, to check it against expected sequences of events and their responses.

PARSERS THAT STREAM IN AND STREAM OUT MEASSAGES TO XML

Statechart diagram for parsing a simple context-free language,

message : '<'string '>'string ';'

FORWARD AND REVERSE ENGINEERING It is possible especially if the context of the

diagram is a class. Using the previous statechart diagram, a forward

engineering tool could generate the Java code for the class ‘X’

The forward engineering tool must generate the necessary private attributes and final static constants

Reverse Engineering is not possible but it allows animation of a model against the execution of a deployed system