Chapter 14. Modeling an Object's State: State Machine DiagramsActivity diagrams and interaction diagrams are useful for describing behavior, but there's still a missing piece. Sometimes the state of an object or system is an important factor in its behavior. For example, if the CMS required potential users to submit an application for an account, which could be approved or rejected, then the AccountApplication object may act differently depending on whether it is pending, accepted, or rejected. In such situations, it's helpful to model states of an object and the events causing state changesthis is what state machine diagrams do best. Continuing the above example, the AccountApplication object could have the states pending, accepted, and rejected as possible values of an attribute, and change states upon events such as approve or reject. A state machine diagram allows you to model this behavior. State machine diagrams are heavily used in special niches of software and hardware systems, including the following:
To reflect these common uses, this chapter will deviate from the CMS example used throughout the rest of this book. Most of this chapter focuses on behavioral state machines , which can show states, transitions, and behavior (inside states and along transitions). There's another type of state machine called a protocol state machine that doesn't model behavior but is useful for modeling protocols such as network communication protocols. Protocol state machines are discussed briefly at the end of the chapter. State machine diagrams are part of the logical model of your system, as shown in Figure 14-1. Figure 14-1. The Logical View describes the abstract descriptions of a system's parts, including when and how those parts can be in different states using state machine diagramsState machine diagrams are often referred to informally as state diagrams. You may also have seen them referred to as a statechart diagrams in the past, since this diagram has undergone many name changes. |