You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Appccelerate’s base extension methods are a great debugging tool. I use them all the time to help debug new state machines or state machines being modified or enhanced.
In a hierarchical state machine with deeply nested substates, it can be quite difficult to debug issues where multiple substates respond to the same event (with or without guards).
For example, suppose C is a substate of B, B is a substate of A, and all have an event handler with guard for event E. If E is fired from state C and C’s guard fails, then B’s E event handler is called. If B’s guard fails, then A’s E event handler is called.
Because each state’s event handler guard can be based on different conditions, and result in different actions/transitions when the guard succeeds, it can be difficult to trace the state machine’s behavior in response to event E.
It would be valuable if you could provide a new base extension method, HandledIn (or some suitably named method), that returns the state that ultimately handled the most recently fired event. In the above example, if event E is fired from state C, and state C and B’s event handlers’ guards failed, but state A’s event handler’s guard succeeded, then HandledIn would return state A. If state A’s event handler’s guard also failed, then HandledIn would return null (unhandled event).
Thanks,
Paul
The text was updated successfully, but these errors were encountered:
prlaba
changed the title
Enhancement: Extension method to return superstate that handled event
Enhancement: Extension method to return state that handled event
May 6, 2018
Nice idea. Maybe it would be better to add this information in the transition context passed to the extension method, or as a new parameter to this method. I'll have to see how it applies in the code.
Appccelerate’s base extension methods are a great debugging tool. I use them all the time to help debug new state machines or state machines being modified or enhanced.
In a hierarchical state machine with deeply nested substates, it can be quite difficult to debug issues where multiple substates respond to the same event (with or without guards).
For example, suppose
C
is a substate ofB
,B
is a substate ofA
, and all have an event handler with guard for eventE
. IfE
is fired from stateC
andC
’s guard fails, thenB
’sE
event handler is called. IfB
’s guard fails, thenA
’sE
event handler is called.Because each state’s event handler guard can be based on different conditions, and result in different actions/transitions when the guard succeeds, it can be difficult to trace the state machine’s behavior in response to event
E
.It would be valuable if you could provide a new base extension method,
HandledIn
(or some suitably named method), that returns the state that ultimately handled the most recently fired event. In the above example, if eventE
is fired from stateC
, and stateC
andB
’s event handlers’ guards failed, but stateA
’s event handler’s guard succeeded, thenHandledIn
would return stateA
. If stateA
’s event handler’s guard also failed, thenHandledIn
would returnnull
(unhandled event).Thanks,
Paul
The text was updated successfully, but these errors were encountered: