Hints and Tips
When you model state machines in the UML, remember that every state machine represents the dynamic aspects of an individual object, typically representing an instance of a class, a use case, or the system as a whole. A well-structured state machine
- Is simple and therefore should not contain any superfluous states or transitions.
- Has a clear context and therefore may have access to all the objects visible to its enclosing object (these neighbors should be used only as necessary to carry out the behavior specified by the state machine).
- Is efficient and therefore should carry out its behavior with an optimal balance of time and resources as required by the actions it dispatches.
Modeling the vocabulary of a system is discussed in Chapter 4 . - Is understandable and therefore should name its states and transitions from the vocabulary of the system.
- Is not nested too deeply (nesting substates at one or two levels will handle most complex behaviors).
- Uses orthogonal regions sparingly because using active classes is often a better alternative.
When you draw a state machine in the UML,
- Avoid transitions that cross.
- Expand composite states in place only as necessary to make the diagram understandable.