Each object is in a particular state at a given point in time. States are represented as rounded rectangles; each state has an identifying name.
States are represented using rounded rectangles — each state has a name that must be unique within a given lexical scope.
States are characterized by the concepts of duration and stability. An object is not always in the same state at a given time, and an object cannot be in an unknown or undefined state. A state is the image of an instantaneous combination of the values contained in the object's attributes, and the presence or the absence of links from the given object to other objects.
The following class diagram represents people that work for companies:
People do not all have a job and are, at any given point in time, in one of the following states: employed, unemployed, or retired.
To understand the situation of a particular person, it is necessary to study the following combinations:
In the diagram below, there are no links between Toto, who is 30 years old, and a company: Toto is therefore unemployed. Cedric, for his part, has a link to a company and is 40 years old: Cedric is therefore employed. Finally, Ernest does not have any link to a company and is 75 years old: Ernest is therefore retired.
The state of the three people is different. Toto is unemployed, Cedric is employed, and Ernest is retired.
The state machines defined by UML are deterministic. Therefore, a statechart diagram must not leave any room for ambiguous constructs. This means, in particular, that it is always necessary to describe the system's initial state. For a given hierarchical level, there is always one and only one initial state. Conversely, it is always possible to have several final states that each correspond to a different end condition. It is also possible to not have any final state — in the case of a system that never stops, for example. The initial state is represented by a big black dot. A final state is represented by a big black dot surrounded by a circle.
© 1997 Editions, Eyrolles, Paris, France . All rights reserved.