State Diagram 1 State Diagram 2 State diagram

  • Slides: 16
Download presentation
State Diagram 1

State Diagram 1

State Diagram 2 �State diagram: Shows the behavior of one object. They describe all

State Diagram 2 �State diagram: Shows the behavior of one object. They describe all of the possible states that a particular object can get into and how the object's state changes as a result of events that reach the object. �Other names: State transition diagram Harel diagram (statecharts)

Events, States and Transactions 3 �Event: is a significant or noteworthy occurrence. Ex: a

Events, States and Transactions 3 �Event: is a significant or noteworthy occurrence. Ex: a telephone receiver is taken off the hook. �State: is a condition of an object at a moment in time (the time between events) Ex: a telephone is in state of being idle after the receiver is placed on the hook and until it is taken off the hook. �Transaction: is a relationship between two states that indicates that when an event occurs, the object moves from the prior state to the subsequent state. Ex: When the event "off hook" occurs, transition the telephone from the "idle" to "active" state.

4

4

State Diagram Syntax 5 �Initial and final states: Initial state denoted by a filled

State Diagram Syntax 5 �Initial and final states: Initial state denoted by a filled black circle and may be labeled with a name. Final state denoted by a circle with a dot inside, and may also be labeled with a name.

State Diagram Syntax 6 �State Action If the target state had many transitions arriving

State Diagram Syntax 6 �State Action If the target state had many transitions arriving at it, and each transition had the same effect associated with it, it would be better to associate the effect with the target state rather than the transitions.

State Diagram Syntax 7 �Self Transitions: A state can have transition that return to

State Diagram Syntax 7 �Self Transitions: A state can have transition that return to itself.

State Diagram Syntax 8 �Compound state A state diagram may include sub diagrams.

State Diagram Syntax 8 �Compound state A state diagram may include sub diagrams.

State Diagram Syntax 9 �Entry point When you won’t want to enter a sub-state

State Diagram Syntax 9 �Entry point When you won’t want to enter a sub-state at the normal initial state.

State Diagram Syntax 10 �Exit point:

State Diagram Syntax 10 �Exit point:

State Diagram Syntax 11 �Choice Pseudo-State Shown as a diamond with one transition arriving

State Diagram Syntax 11 �Choice Pseudo-State Shown as a diamond with one transition arriving and two or more transitions leaving.

State Diagram Syntax 12 � Junction Pseudo-State used to chain together multiple transitions. A

State Diagram Syntax 12 � Junction Pseudo-State used to chain together multiple transitions. A single junction can have one or more incoming, and one or more outgoing, transitions.

State Diagram Syntax 13 �Terminate Pseudo-State The lifeline of the state machine has ended.

State Diagram Syntax 13 �Terminate Pseudo-State The lifeline of the state machine has ended.

Example 14

Example 14

Example 15

Example 15

Example 16

Example 16