State
Diagrams:
State Diagrams State diagrams are created during the analysis and design phase
to describe the behaviour of nontrivial objects. State diagrams are good for
describing the behaviour of one object across several use cases and are used to
identify object attributes and to refine the behaviour description of an
object.
There are three major components of a
state diagram:
State:
A state is a condition in which an
object can be at some point during its lifetime, for some finite period of.
State diagrams describe all the possible states a particular object can get
into and how the objects state changes as a result of external events that
reach the object.
States are
represented by the values of the attributes of an object.
A state
represents a stage in the behaviour pattern of an object, and in a state
diagram it is possible to have
initial states and final states.
An initial
state, also called a creation state, is the one that an object is in when it is
first created, whereas a final state is one in which no transitions lead out
of.
. In a state diagram:
• A state is represented by a rounded
rectangle.
•
A start state is represented by a solid circle.
• A final state is represented by a
solid circle with another open circle around it.
Transition
A
transition is a progression from one state to another and will be triggered by
an event that is either internal or external to the object.
Transitions
are the result of the invocation of a method that causes an important change in
state.
A
transition is a change of an object from one state (the source state) to
another (the target state) triggered by events, conditions, or time.
Transitions are represented by an arrow connecting two states.
Transitions can also be labeled with
guards (a Boolean expression which evaluates to true or false) inside square
brackets, such as [trade accepted]. A guarded transition occurs only if the
guard resolves to true. Only one transition can be taken out of a given state.
If more than one guard condition is true, only one transition will fire. The
choice of transition to fire is nondeterministic if no priority rule is given
The arrows
in state
diagram represent
transitions, progressions from one state to another.
Event: Is
something that occurs at a point of time.
Events are
internal or external factors influencing the system.
Event causes the transitions
State
diagrams are used to model states and also events operating on the system.