UML: State Chart Diagrams Sabbir Muhammad Saleh SAD ::: Fall ::: 2015
Statechart Diagrams difference between Statechart diagrams and Activity diagrams: Statechart diagrams are used to represent a single object and how its behavior causes it to change state Activity diagrams are used to model how different areas of work behave with each other and interaction
Statechart Diagrams: Components a statechart diagram is composed by three components: - state - transitions - events
Statechart Diagrams: What’s “State” state is defined as a snapshot or a milestone of an object’s behavior at a particular point in time on Computer booting processing can be in the following states: idle Shutting down off
Statechart Diagrams: Components – State there are three separate notations for states in the statechart diagram: State State Start State End State
Statechart Diagrams: Components – State a statechart diagram can include zero or more start states a statechart diagram can include more than one end states
Statechart Diagrams: Components – Transitions transitions are used to show flow from one state to another State A State B
Statechart Diagrams: Components – Decision Points decision points make the diagram more visually appealing by grouping transitions State A State B State C
Statechart Diagrams: Components – Synchronization synchronization bars are used to show where states need to catch up with or wait up for others State A State B
Statechart Diagrams: Components – Actions and Events actions and events are used to describe how states are reached, what happen when they are reached, and what happen when they are exited
Statechart Diagrams: Components – Actions and Events events are indicated directly on the path of a transition from a state to another state Reset Deleted Cancel Data Entered Clean Dirty Continue Saved New
Statechart Diagrams: Components – Actions and Events an action shows what behavior happens when an event occurs, there are five basic action types: - entry (action that occurs when state has been entered) - exit (action that occurs when state is being abandoned) - do (action that occurs when state is being occupied) - include (invokes a submachine) - event (used to specify the action that occurs when a specific event is fired)
Statechart Diagrams: Components – Actions and Events Exit / Reset Deleted Cancel / EmptyData() Data Entered / RecordData() Clean Dirty Continue / SaveData() Saved Exit / Reset
Statechart Diagrams: Components – SubStates used to model hierarchical states Event A [condition 1] Event A [condition 2] Event A State A State A State 1 State 2
Statechart Diagrams: Components – Composite States used to model hierarchical states State B State A State 1 State 2
Statechart Diagrams: how to build models there are five steps - identify the entities (objects or use cases) that need to be further detailed - identify the start and end states for each entity - determine the events relating to each entity - create the statechart diagram beginning with the start event - create composite states where necessary