0

I need some suggestions. I am trying to implement an online order process through Spring state machine and am trying to construct a state diagram before I get to work. Now say my order can be canceled by three different admin users CanceledByAdmin1,CanceledByAdmin2 and CanceledByAdmin3. Should I make them substate of Cancel state or create three different states? Keeping in mind that all canceled states are the final states and independent of each other, I don't know if making substates does anything other than simplifying the paper diagram. Any help would be appreciated.

user
  • 169
  • 1
  • 12

1 Answers1

0

What comes for Spring Statemachine we can have only one terminate state and trying to make that as collection of substates is a bit awkward because once you enter it, state machine should stop all processing. Thought this area is something what I've probably overlooked and could try to enhance things.

While you could probably have a state S1 having three substates S11/S11E,S12/S12E andS13/S13E with triggerless transition from S11 to S11E and same with other substates, even this feels a bit weird because none of those would actually terminate root state machine.

I guess question is what you're trying to accomplish?

If you only want to keep that information around who/which cancelled the order, could you use a simple single terminate state and during a transition to that terminate state, add/modify extended state variables with this info.

Extended state variables are usually used to overcome these problems of suddenly having astronomical count of states to keep arbitrary information around. I know that in this example you only have three, but what about if you have 10, or 100? If you actually need to add even one more, you need to change state machine configuration and recompile. With extended state variables you would not need to do that.

Janne Valkealahti
  • 2,552
  • 1
  • 14
  • 12
  • Got it. Anyways Janne we need to start using FSMs in our ecommerce project. Our idea is to develop our own state machine for order process life cycle. Now I am thinking of using Spring statemachine. What do you suggest? Do you have any idea how long before state machine is generally available? – user Aug 12 '15 at 10:54
  • If you don't require that much features from a machine and your own implementation would be very simple one-time development, I don't see anything wrong with that approach. It's just that after you need to start adding features, internal machine structure gets almost exponentially more complex. Believe me, been there, done that. We're planning to get into 1.0.0.RC1 in a month by SpringOne. From RC1 to RELEASE, I'd say 1-2 months. Just an estimate but probably rather accurate. – Janne Valkealahti Aug 12 '15 at 16:57