yohang / Finite

A Simple PHP Finite State Machine

Home Page:http://yohan.giarel.li/Finite

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wildcard transition state

sagikazarmark opened this issue · comments

There can be some cases when one part of the transition should be a wildcard, so that the state can change TO ANY or can change FROM ANY.

Example:
Customer service operator takes a phone call and starts a customer process. Then the customer suddenly hangs up the phone. What can the operator do? Interrupt the process, no matter where it was before. Then the customer calls again. What can the operator do? Start a new process, or put the interrupted process into a specific state (of course contolled by the application, based on the previous processes).

+1
I would also need transition wildcard for FROM ANY state. Example would be for order that can be FAILED from any state.

I don't know how would TO ANY work, since it wouldn't know what state to move to in that case.

👎 because there will always be states you shouldn't be able to transition to or from. A final state may by definition not be used as from. An initial state could be undesirable to transition to.

Thinking about your example I think a better approach would be to create an interrupted state that you can move from any of your call active states. The interrupted state can transition to restarted or something which can move back to probably a few or all or your active call states.

@sagikazarmark I understand your need, but I agree with @RonRademaker as the graph should stay a simple graph with initial and final state.

The solution of an interrupted state is pretty good, but it won't be part of 1.1.

I think the interrupted state doesn't have to be in the component, @sagikazarmark can simply add it to the statemachine.