Information Analysis:State transition diagrams

8.7 State transition diagrams

The class model has defined the structural aspects of the system and interaction diagrams show how objects interact to achieve a specific purpose, as defined by a use case. As we have seen already, an object can take on a number of states at different times – is the seat at performance available, reserved, or booked? More formally, a state is a 'condition or situation in the life of an object during which it satisfies some condition, performs some activity, or waits for some event' (Booch et al., 1999, p. 333).

Developing Web Information Systems-0087

An event is something that happens in space and time: 'user clicks on button', 'it begins to rain', 'I've been waiting for 5 minutes in a telephone queue'. It is events that trigger changes in the state of objects – a state transition. When a user clicks on a button the result might be to maximize a window on the screen, i.e., a state change for the window from minimized to maximized. If it starts to rain then person changes to person with open umbrella; if I have been waiting for 10 minutes I will cancel my call and become a dissatisfied customer.

Developing Web Information Systems-0088

A state transition diagram shows the different life-cycles that an object of a class can undergo. The state of an instance is given by the attributes and associations it has. For example, a seat at performance that has been booked will have an association with a transaction object. States are shown as rounded rectangles and transitions as arrows. The labels on the transitions are of the form:

event [guard]/action

In figure 8.20 the transitions are labelled with events, such as 'Die', 'Marry', and 'Divorce'. In the United Kingdom it is necessary to get divorced before remarrying. If polygamy is allowed then a married person can get married again without being divorced. This is shown as a self-transition in figure 8.20 and a guard has been added to ensure that this transition can only take place if 'Polygamy OK' (of course, although our model is accurate from a legal standpoint, it does not stop people committing bigamy). The state transition diagram is a template. It describes the possible paths that an object might take. For example, some people will be born and die without getting married.

Others will marry once and others might marry multiple times. By definition, an object must have a state and can only be in one state at any one time.

State transition diagrams are prepared for those classes that have sufficiently complex states and transitions to warrant modeling. Some classes will have simple states and transitions going directly from creation to destruction. Others will have more complex behaviour, such as objects in the class Seat At Performance (figure 8.21).

The state transition diagram therefore represents the possible life-cycle of objects of a given class. It is closely related to the sequence diagram, which shows the message passing that will result in state changes in objects.

Comments

Popular posts from this blog

The Conversion Cycle:The Traditional Manufacturing Environment

The Revenue Cycle:Manual Systems

HIPO (hierarchy plus input-process-output)