Presentation is loading. Please wait.

Presentation is loading. Please wait.

State Change Modelling. Aim: To introduce the concept and techniques for describing the changes in state that may occur to an object in its lifetime.

Similar presentations


Presentation on theme: "State Change Modelling. Aim: To introduce the concept and techniques for describing the changes in state that may occur to an object in its lifetime."— Presentation transcript:

1 State Change Modelling

2 Aim: To introduce the concept and techniques for describing the changes in state that may occur to an object in its lifetime.

3 State Change Specification ● “A state change specification is a dynamic model that shows the different states that a single object passes through during its life in response to events, along with its responses and actions” (Dennis et al 2004) ● The state of an object is determined by the values of its attributes ● The modelling of object states is done with statechart - or state transition - diagrams – a graph consisting of states, events and transitions ● State models are built for each class that exhibits interesting dynamic behaviour

4 Example

5 Basic Elements ● State – a set of values that describe an object at a specific point in time ● e.g. when the object satisfies some condition ● e.g. when the object performs some action ● e.g. while the object waits for something to happen – depicted by a state symbol – a rectangle with rounded corners ● labelled with a meaningful name – special states ● initial state (solid filled circle), final state (bull's eye)

6 Basic Elements ● Transitions – arrows connect states – labelled with a transition string – transitions are triggered by events ● change event: occurs when a condition (usually boolean) becomes true – syntax: when '[' condition ']' ● call event: occurs when an object receives a call for one of its operations ● signal event: occurs when an object receives a signal (asynchronous communication) ● time event: caused by the passing of a period of time

7 Syntax of events ● Transition strings for call and signal events – event-signature '[' guard-condition ']' '/‘ action-expression ● event-signature – event-name '(' parameter-list ')' ● guard-condition – a boolean expression ● action-expression – is executed when an event triggers the transition to fire – may comprise an action or sequence of actions

8 Event Example

9 Statechart for class Campaign

10 More Elements ● Optional activities and internal transitions – internal actions or activities associated with a state ● 'entry' '/' action-expression ● 'exit' '/' action-expression ● 'do' '/' activity-name '(' parameter-list')' ● 'include' '/' substate – a list of internal transitions ● event-signature '[' guard-condition ']' '/' action-expression '^' send-clause ● the send-clause syntax – destination-expression '.' destinationevent- name '(' argument ','... ')'

11 Example

12 Menu Visible State for a DropDownMenu Object

13 More Elements ● A state may have nested substates – or-substate ● a state has substates, but can only be in one substate at a time – and-substate (concurrent substates) ● a state may have many concurrent substates ● Used to manage complexity and keep diagrams simple

14 Nested Substates Example

15 The Active state with Concurrent Substates

16 Preparing Statechart: A Behavioural Approach 1. Examine all interaction diagrams that involve classes with heavy messaging 2. Identify the incoming messages that may correspond to events and identify the possible resulting states 3. Document these events and states on a statechart diagram 4. Elaborate the statechart as necessary 5. Develop any nested statecharts 6. Review the statechart to ensure consistency with use cases 7. Iterate steps 4, 5 and 6 8. Check the consistency of the statechart with the class diagram, interaction diagrams and other statecharts

17 Consistency Checking ● Consistency rules – every event in a statechart should appear as an incoming message for the appropriate object in an interaction diagram – every message in an interaction diagram corresponds to an operation in a class diagram – every action in the statechart should correspond to the execution of an operation on the appropriate class – every state in a statechart must be captured by an attribute in a class diagram – every outgoing message sent from a statechart must correspond to an operation on another class

18 summary State models show the different states that a single object passes through during its life in response to events, along with its responses and actions Modelling state changes is done towards the end of the analysis phase Object state specification – states, transitions, events, conditions, actions Always check for consistency between models References – Maciaszek, chapter 4, Bennett et al, chapter 11


Download ppt "State Change Modelling. Aim: To introduce the concept and techniques for describing the changes in state that may occur to an object in its lifetime."

Similar presentations


Ads by Google