Return to Website   
Quantum Leaps Discussion Forum

Search the Forum for answers or post your questions to the
Quantum Leaps community



Return to Website

  Reply
  Forum

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:    
Re: event handling question by Tad Ashlock · Jul 11, 08 - 5:58 AM
Re: event handling question by Miro Samek · Jul 14, 08 - 9:29 AM
Re: event handling question by mikec · Jul 14, 08 - 11:53 AM
Re: event handling question by Miro Samek · Jul 14, 08 - 12:12 PM


  Reply
  Forum


powered by Powered by Bravenet bravenet.com