- A State Diagram is a graph whose nodes are states and arcs ar the transition between the states caused by the event.
- State diagram specifies state sequence caused by an event sequence.
- State name must be unique within the scope of state diagram.
- A state diagram relates events and states. A change of state caused by an event is called transition. All the transitions leaving a state must correspond to different events.
- The state diagram specifies the state sequence caused by an event sequence.
- Also, If an object is in a state and an event labeling one of its transitions occurs, the object.
- Enters the state on the target end of the transition. The transition is said to fire.
- A sequence of events corresponds to a path through the graph.
- There are two types of state diagram
- Sample State Diagrams
- One-Shot State Diagrams
Sample State Diagrams
- State diagrams wit a continuous loop.
- Sample state diagram represents an object with infinite life.
One-Shot State Diagrams
- The one-short diagram represents an object with finite lives and has initial and final states.
- Moreover, An initial state entered on the creation of an object while entry of final state implies the destruction of an object. You can indicate initial and final states via entry and exit points.
- Also, Entry points (hollow circles) and exit points (circle enclosing an “x”) appear on the state diagram’s perimeter and may name.
State Diagrams Behavior
- Application of State diagram not just limited to the description of events.
- Also, A full description of an object must specify what the object does in response to events.
- The effect a reference to a behavior that executed in response to an event.
- Moreover, An activity is an actual behavior that can invoke any number of effects.
- E.g. disconnect Phone Line might be an activity that executed in response to hang up event.
- Also, Activities can also represent internal control operations, such as setting attributes or generating other events.
- Such activities have no real-world counterparts but instead are mechanisms for structuring control within an implementation.
- E.g. program might increment an internal counter every time when the specific event occurs.
- Moreover, State diagrams activity denoted as the slash (“/”) and name or description of the activity, following the event that causes it.
- Also, As shown in figure below, when the right button pressed, a menu displayed when it released, a menu erased. While the menu visible, the highlighted menu item updated whenever cursor moves.