| Subject: |
|
event handling question |
| Name: |
|
mikec |
| Date Posted: |
|
Jul 11, 08 - 1:10 AM |
| Message: |
|
Hi,
I was wondering if somebody could help me find an elegant solution to the following problem. I have 3 states: A, B, and C. All three states handle a common event type. The first part of handling the event is specific to the state. However, the second part of handling the event is common to all three states. Here is some pseudocode for handling the event in state A:
// Step 1. The first action is specific to this state.
Processing_Specific_To_State_A()
// Step 2. The following actions are the same for states A, B, and C.
if (guard1)
...transition to state D
else if (guard2)
...transition to state E
else
...transition to state F
I'd like to avoid the code duplication of step 2 since it is common to states A, B, and C. However, I can't simply handle the event in the super state because step 1 needs to be handled specifically by the sub state. I'd appreciate any suggestions.
Thanks,
- Mike |
|
Replies:
|
|
|
|
|