Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Extension method to return state that handled event #34

Open
prlaba opened this issue May 6, 2018 · 2 comments
Open

Enhancement: Extension method to return state that handled event #34

prlaba opened this issue May 6, 2018 · 2 comments

Comments

@prlaba
Copy link

prlaba commented May 6, 2018

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

@prlaba 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
@ursenzler
Copy link
Member

Hi Paul

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.

Cheers,
Urs

@prlaba
Copy link
Author

prlaba commented May 8, 2018

Thanks Urs, whatever implementation works best to identify the state that handled the event is fine by me.

Paul

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants