The scenario:
I have a simple state machine:
Happy path:
Uninitialized->Initialized->InProgress->Done
Unhappy path:
Uninitialized->Initialized->Error
Simply put, I need to cause a transition (either into InProgress or in Error state) without an external event/trigger. I.e. Initialized state should immediately result in one of those states.
Questions:
- Is it OK to cause state transition from within Initialized.Enter() ?
- I could use state guards to do this, but I'd rather not have non-trivial logic in the state guard (and initialization can very well be complex).
- If it is NOT OK, how can I do it differently?
- Should I just take this decision out of he FSM all together and have some other component cause the appropriate transition? But then, wouldn't I still have to call that external component from within Initialized.Enter() ? so it solves nothing?