State Diagrams

In next lessons you'll work with elements that you haven't worked before. That would be behavioral elements, that show how parts of a UML model change over time. As the system interacts with users and possibly with other systems, the objects that make up the system go through necessary changes to acommodate the interactions. If you're going to model systems, you must have a mechanism to model change. That mechanism in UML is State diagrams.

- When you pull a switch, a light changes its state from off to on.
 - When you make keystroke or mousemovement in screen saver mode on your computer, your computer leaves screen saver mode and returns to working - active mode.

The UML State diagram presents the states an object can be in along with the transitions between the states, and shows the starting point and endpoint of a sequence of state changes.

A state diagram shows the states of a single object.


States in the state diagram are represented with a rounded rectangle, and the symbol for the transition is a solid arrowhead line. A solid circle stands for starting point of a sequence of states, and bull's eye represents the endpoint.

The UML symbols in a state diagram. The top area stands for the state's name, middle area is for state variables, and the bottom is for activities. Transitions are represented with solid arrowhead lines, and circles are for starting and ending state.

Also you can add details to a state icon by dividing it to a three areas. The top area holds the name of the state (this name you must supply whatever the class is divided or not), the middle area hold state variables (timers, counters, dates...), and the bottom area hold activities (entry-what happenes when the system enters the state, exit-what happenes when the system leaves the state, do-what happenes when the system is in the state).