The very last diagram that I want to discuss is
the state transition diagram. The state transition diagram is defined for
each relevant class in the system and basically shows the
possible live history of a given class or object. So what
does it mean to describe the life history? It means
that it describes the possible states of the class as defined
by the values of the class attributes. And it also describes
the events that cause a transition from one state to another.
Finally, it describes the actions that result from a state
change. So if you put all of this together you
can see how this can represent the whole history of
the class, from its creation to its destruction. So let me
discuss the transition diagram in more detail, and also provide
information about the notation used to represent them. We have
states, that are represented by ovals with a name. And
we have transitions marked by the event that triggers the transition.
What transitions indicate is the passage from one state to
another state as the consequence of some external stimuli. Notice
that not all events will cause a state transition. So
for example, some events might be consumed within a single state.
And we'll get to that in a second. But in
most cases, an event will trigger some state transition. Events
may also produce actions and they may also have attributes
which are analogous to parameters in a method call. And Boolean
conditions that guard the state transition that is prevented
from happening in the case the conditions are not
satisfied. States may also be associated with activities and
actions. Specifically, activities are operations performed by an object
when it is in a given state and that
takes time to complete. Actions, conversely, just like the
actions corresponding to an event are instantaneous operations that
are performed by an object. And can be triggered
on entry. So, when the object reaches a given state,
when the object exits that state, and also when a
specific event occurs. And in this case, this notation is
basically a shortcut for any event that will cause a
state transition that will bring the object back into the
same state. Since we have several actions and activities, it
is probably worthwhile clarifyinig the ordering of such actions and
activities. So the way in which these actions and activities
occur is, first of all, we have the actions on the
incoming transition, so this is performed first. Then if there is an
entry action that is the next action that would be performed, then
we have activity and event actions as appropriate. And finally exit actions.