05 State Chart Diagram
05 State Chart Diagram
In this notation, the object can be in any one of the following sets of states:
• State A, State B and State 1 and State 2
In the left diagram, Event A is causing the state of the object to change from State A to State B.
In the right diagram, Event A is causing the object to move from the start state to either State 1
or State 2 depending upon Condition 1 or Condition 2.
Example: State Chart Diagram
• When a project is loaded, the object enters the Editing state.
• From there, the project can be unloaded to exit the statechart diagram, but it
can also be Run to enter the Running state.
• The Running state is further described in the second statechart diagram, and
the Run event is guarded that determine which transition is chosen.
• If the mode of the object is Debug, then the Debug state is chosen, thus
making the object in the Running and Debug states at the same time.
• Similarly, if the mode were equal to Release, then the Optimization Mode
state would also be active along with the Running state for the object.
State Chart Diagram: Composite State
• Another way to illustrate substates is by using the notation for composite
states.
• Composite states are modeled by creating a very large state and embedding
the substate statechart within it
State Chart Diagram: Composite State
Draw a flow char for the following description:
valid states (not including the start or end states) for the preceding location:
– Full Time Student
– Probationary Student and First Degree Probation
– Probationary Student and Second Degree Probation
– Expelled Student
• Once a student is added to the roster, the Full Time Student state is valid.
• A Probation event will make you a Probationary Student depending upon the
severity.
– From there, you can get a Reprieve event and go back to being a Full Time
Student.
– Full Time Student cannot get to Expelled Student without becoming a
Probationary Student, and a Probationary Student will become an Expelled
Student with a Probation event regardless of what the substate value is (First or
Second Degree Probation).
Composite State – Example - Solution
How to Model State Charts
State Chart
for Grade
Object
How to Model State Chart Diagram
(4) Specify the Composite States Where Necessary
• In the example, we can
consider Persisting to
be very general
• we can give substates
that would include
either Load, Update
and Save, or simply
Insert.
Practice Example
• Consider the point-of-sale system and create a statechart diagram describing how
it accepts orders, processes them, and debits inventory upon success.