| Subject: |
|
Re: Concept of Composite State and Sub-state |
| Name: |
|
Miro Samek |
| Date Posted: |
|
Jul 31, 08 - 10:18 AM |
| Email: |
|
miro@quantum-leaps.com |
| Website: |
|
http://www.quantum-leaps.com |
| Message: |
|
Section 4.3.3 on page 104 in PSiCC1 (PSiCC book, First Edition) answers your question 1. In quick summary, a composite state (a state with substates) does *not* have to provide an initial transition. However, UML requires that "if a composite state is active then exactly one of its substates is active". To satisfy the UML requirement without the initial transition in a composite state by using transitions that always target substates of the composite state and never the composite state directly. The aforementioned Section 4.3.3 in PSiCC1 proposes relaxing the UML rule.
As to question 2 ("How to design good hierarchical state machines?"), I can't give a short answer. Good HSM design is in many ways like good object-oriented design. The experience comes with practice, studying effective designs, and lots of thinking. Chapter 5 (both in PSiCC1 and PSiCC2) offers a mini-catalogue of five state design patterns, as a starting point. (The state patterns in PSiCC2 are more complete and implemented with the QF framework.) Also, PSiCC2 provides many more state machine examples, such as the "Fly'n'Shoot" game, Time Bomb, Calculator, Dining Philosophers, PELICAN crossing, and others. Some new interesting examples of state machines and *systems* of state machines should appear on the www.state-machine.com website within the coming months.
Miro |
|
|
|
|
|
|