not consistent start of state machine

107 views
Skip to first unread message

Martin

unread,
Jul 15, 2013, 10:27:16 PM7/15/13
to dotnet-state-ma...@googlegroups.com
Hello,

just simple issue that I came across finding that . When does actually state machine start to be 'in initial state' ?

- after constructor?
- after number of ".Configure" commands?

If after constructor, then I find it inconsistent, because it should fire "OnEntry" function as it enters initial state. Of course it does not fire because at this point it has not reached ".Configure" commands and does not know about. And it won't launch after ".Configure" because it's already in state.

What I liked particulary is approach taken by bbv state machine: it has commands Start(initial_state) and stop, so after configuration lines I can correctly start working and enter first state with all callbacks/stuff launched behind.

I see that there is second overloaded list of constructor arguments with Mutator action. Can someone explain me 

What do you think?

Greetings
Marcin

Grant BlahaErath

unread,
Jul 16, 2013, 12:13:02 PM7/16/13
to dotnet-state-ma...@googlegroups.com
If you disregard the OnEntry methods as side-effects that exploit the
state machine's logic, then the initial state is the one that is set on
construction. While correct as an FSM implementation, its not as useful.

In practice, you want the initial state to have no Entry or Exit
functions, and be configured to advance to the second state without
conditions. Then fire a trigger to enter the second state to begin the
working state machine. On that second state you attach all the things
you want to effect when the state machine begins. If the machine needs
to loop through different states, never return to the initial state,
only loop back to the second state.

-g
> --
>
> ---
> You received this message because you are subscribed to the Google
> Groups "Stateless .NET State Machine Framework" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to dotnet-state-machine-...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Martin

unread,
Jul 21, 2013, 8:00:02 AM7/21/13
to dotnet-state-ma...@googlegroups.com
As simple as that, thank you Grant for response, i'll fix it according to your idea.

Greetings
Marcin
Reply all
Reply to author
Forward
0 new messages