Composite States and Submachines


The text in the section "States and Transitions" addressed what are officially called simple states. These are states that have no substates nested within them.

A state that has one or more nested substates is called a composite state. Composite states come in two forms: those that contain sequential, or disjoint , substates and those that contain concurrent substates. The following subsections discuss both types of composite states.

Sequential Substates

A sequential substate is a substate in which an object can reside to the exclusion of all other substates at that same level within the given composite state. Given two or more sequential substates at the same level, an object can be in only one of them.

Figure 7-17 shows three examples of sequential substates within the Retrieving Books composite state.


Figure 7-17: Sequential substates

When an Order object enters the Retrieving Books state, the object also enters the Accumulating from Inventory substate. If the system is able to retrieve all the books for the Order from inventory, the object leaves the Accumulating from Inventory substate and the Retrieving Books state and enters the Packaging state. On the other hand, if there are any books on back order, the Order enters the Waiting for Back Order substate, where it remains until the back-ordered books arrive .

At that point, the object enters the Accumulating from Back Order state, and at some point, the object leaves that substate and the enclosing state and enters the Packaging state. Regardless of what substate the object is in when it leaves the Retrieving Books state, though, the last thing that happens is execution of the postToGL exit action.

Concurrent Substates

A concurrent substate is a substate in which an object can reside simultaneously with other substates at that same level within the given composite state. Given two or more composite substates at the same level, an object may be in one or more of them.

In this situation, two or more sets of substates can represent parallel flows of control. When the object enters a composite state with concurrent substates, the object also enters the initial states of each set of substates. Just like on an activity diagram, you can resynchronize these parallel flows. On a state diagram, however, you show this resynchronization by using a final state for each parallel set of concurrent substates.

Figure 7-18 shows how you use the UML to represent some concurrent substates that belong to the Shipping state, another one of the states in which an Order object can reside.


Figure 7-18: Concurrent substates

When an Order object enters the Shipping state, the object also enters the Filling Out Shipping Slip substate and the Posting Final Amount to GL substate at the same time. Work proceeds along both paths in parallel; there are no dependencies between the activities associated with the Physical path and those in the Financial path . Once the Order reaches the final states along both paths (represented by the "bull's-eyes"), the object leaves the Shipping state.

Note that Physical and Financial represent regions of the composite state Shipping, where each region contains its own concurrent substates and transitions.

Transitions in and out of composite states with concurrent substates work the same way as do transitions for states with sequential substates. You can also use a history state in conjunction with concurrent substates.

Here are some other relevant facts about sequential and concurrent substates:

  • A substate within a composite state can have any or all of the details that can be associated with a regular state, such as entry actions, activities, and deferred events.

  • A source state, which resides outside a given composite state, can have an associated transition whose target state is either the composite state as a whole or any one of the substates that compose that state. (If the target of the transition is the composite state itself, you start with the initial state symbol in tracing the flow.)

  • Similarly, a transition can come out of a substate and then leave the enclosing composite state without having to go through the other substates.

Submachines

A submachine is a state machine that can be invoked as part of one or more other state machines. A submachine state is a state that references a submachine such that a copy of that submachine is implicitly part of the enclosing state machine where the reference occurs.

Within Figure 7-19, there is a reference to the Shipping composite state, which is partially defined in Figure 7-18. (A submachine state is semantically equivalent to the composite state defined by the referenced state machine.)


Figure 7-19: Submachine state

Note that an entry point or an exit point (see the section "Pseudostates," earlier in this chapter) can serve as a connection point reference, which represents a usage, as part of a given submachine state, of an entry point or exit point defined in the state machine that the submachine state references. The notation for a connection point reference is the same as that for a regular entry point or exit point.




Fast Track Uml 2.0
Fast Track UML 2.0
ISBN: 1590593200
EAN: 2147483647
Year: 2004
Pages: 97

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net