State transition diagrams
State transition diagrams
30.1 Purpose
The purpose of a state transition diagram is to represent a system as a series of states and related activities, display the interrelationships among the states, show how the system moves from state to state, and document the sequence and priority of the states. State transition diagrams were initially developed to help design compilers. Systems analysts and information system consultants use state transition diagrams to analyze and design real-time and object-oriented systems.
30.2 Strengths, weaknesses, and limitations
State transition diagrams are excellent tools for representing the precedence relationships between a system’s processes and states and for representing recursive and feedback structures. They are particularly useful when a system exhibits multiple changes of state or requires synchronization. A state transition diagram is easily converted into object-oriented code.
State transition diagrams are used primarily in real-time and/or object-oriented systems analysis and design and to support such computer science applications as compiler design. They are not generally useful for designing or documenting batch processing systems. Also, because they are not considered standard tools in the traditional systems analysis and design methodologies, many systems analysts and information system consultants are unfamiliar with them.
30.3 Inputs and related ideas
State transition diagrams are used primarily for analyzing and designing real-time (Chapter 73) and object-oriented (Chapters 6, 29, and 66) systems. They are sometimes used to support prototyping (Chapter 31) and rapid application development (Chapter 32).
30.4 Concepts
A state transition diagram is used to represent a system as a series of states and related activities, display the interrelationships among the states, show how the system moves from state to state, and document the sequence and priority of the states.
30.4.1 Basic elements
Figure 30.1 shows the basic elements of a state transition diagram. The various states (or nodes) are shown as circles. State 0 is the initial (starting) state. Arrows representing functions or activities link a state to its accepting (or following) states. An arrow that originates and returns to the same state represents a recursive loop. The initial and final states are shown as double circles.
On a non-deterministic state transition diagram, a given input function is associated with more than one transition from the state. A deterministic state transition diagram, in contrast, can have at most one transition from a given state for any given input. Deterministic is a special case of non-deterministic.
30.4.2 An example
Figure 30.2 shows, for example, an entity relationship diagram for a real-time system for producing grape jam. State 0 is the initial state. During activity A, the initial mix of raw materials is prepared and the production process begins.
Figure 30.1 The basic elements of a state transition diagram.
State 1 is a target temperature. The production process cannot move on to the next state until the target temperature is achieved, so activity B is a recursive loop during which the temperature of the mix is constantly monitored and adjusted.
After the mix reaches the appropriate temperature, it moves on (activity C) to the next state. State 2 is the target acidity ratio which must be rechecked and balanced after each succeeding state is completed. Activity D adds artificial color to the mix. State 3 is the target color. Activity E is a feedback loop to state 2, where acidity is rechecked.
When both acidity (state 2) and color (state 3) are in balance, sugar is added to the mix (activity F) until the desired level of sweetness is reached (state 4). Activity G is another feedback loop to state 2. Activity H returns the process to state 4, where sweetness is rechecked. When the mix reaches the desired acidity, color, and sweetness, it moves on to the packaging stage (activity I), and the production process ends (state 5).
Figure 30.2 A state transition diagram for a real-time production system.
30.4.3 Fence diagrams
A state transition diagram can also be prepared in the form of a fence diagram. On a fence diagram, the states are shown as vertical lines and the activities that move the system from one state to another are shown as horizontal arrows.
For example, Figure 30.3 shows a fence diagram of the life cycle of a single object in inventory. Starting at the left, the object is ordered, received, inspected, and either accepted or returned to the supplier (the left-pointing arrow).
Once the object is accepted, it is stored in the warehouse. From the warehouse, the object can be transferred to the showroom or returned to the supplier. Objects in the showroom can be sold and delivered to a customer. If the customer accepts the object, it is deleted from inventory records. If the customer rejects the object, it is returned to the showroom where it can be resold or returned to the warehouse.
Figure 30.3 A fence diagram of the life cycle of a single object in inventory.
30.5 Key terms
- Activity (function) —
- A process or event that moves a system from one state to another.
- Deterministic state transition diagram —
- A state transition diagram in which a given input function is associated with at most one transition from a given state.
- Feedback —
- The return of a portion of a system’s output to its input; on a state transition diagram, a feedback loop returns the system to a previous state.
- Fence diagram —
- A state transition diagram on which the states are shown as vertical lines and the activities are shown as horizontal arrows.
- Node—
- A symbol (usually a circle) on a state transition diagram that represents a state.
- Non-deterministic state transition diagram —
- A state transition diagram in which a given input function is associated with more than one transition from the state.
- Real-time system —
- A system designed to respond immediately to real - world events.
- Recursion —
- The ability of a subroutine to call itself.
- State —
- A condition or mode of being, particularly with regard to phase, form, composition, or structure.
- Transition —
- A movement or shift from one state to another.
30.6 Software
The state transition and fence diagrams in this chapter were prepared using Visio. Other graphing tools, such as Micrografx’s Flowcharter provide comparable support. Additionally, many CASE products support state transition models.
30.7 References
- 1. Aho, A., Sethi, R., and Ullman J., Compilers: Principles, Techniques, and Tools, Addison-Wesley, Reading, MA, 1986.
- 2. Davis, W. S., Business Systems Analysis and Design, Wadsworth, Belmont, CA, 1994.
- 3. Martin, J. and McClure, C., Diagramming Techniques for Analysts and Programmers, Prentice-Hall, Englewood Cliffs, NJ, 1985.
Comments
Post a Comment