Howto: State machine with sub states?

184 views
Skip to first unread message

Anders Lybecker

unread,
Aug 21, 2012, 3:21:32 AM8/21/12
to dotnet-state-ma...@googlegroups.com
Hi,

I’m wondering how I should use StateLess.Net in the following scenario:

Imagine an order processing system with orders and order lines. Each order line can have different states (approved, send to supplier, item received …) and so can the entire order – e.g. either the entire order as a hole can be approved or individual order lines.

Can I model that with StateLess.Net? How?

Regards,
Anders Lybecker

Simon Mingaars

unread,
Aug 21, 2012, 3:34:58 AM8/21/12
to dotnet-state-ma...@googlegroups.com
Hi,

I would try to make an "order" and and "orderline" class, which each have there own stateless based state machine. Or you could try to have the orderline as substates for order, but that depends on the dependencies between order and orderlines.

Good luck!


Simon Mingaars

Anders Lybecker

unread,
Aug 21, 2012, 3:41:01 AM8/21/12
to dotnet-state-ma...@googlegroups.com
Hi Simon,

But in the case where there is a dependency between the states in order and orderline? E.g if each orderline is approved then the entire order is approved.

Is it possible for a state transition on order to be dependent or the orderlines states?

Regards,
Anders Lybecker

Simon Mingaars

unread,
Aug 21, 2012, 4:23:27 AM8/21/12
to dotnet-state-ma...@googlegroups.com
Offcourse, just make a transition from the orderline to the order "approved" state.

Regards,

Simon

Anders Lybecker

unread,
Aug 21, 2012, 4:30:04 AM8/21/12
to dotnet-state-ma...@googlegroups.com
How can I make the order transition dependent on sub states on order lines?

Simon Mingaars

unread,
Aug 21, 2012, 4:34:44 AM8/21/12
to dotnet-state-ma...@googlegroups.com
Just make another transition.

For example:

Order States (Substate)
Approved  -----transition----->  Pending ----transition------> Executed
                                                                                            |
                                                                                            |
                                                                                      transition
                                                                                            |
Orderline States (Superstate)                                                 \/
Approved  -----transition----->  Pending ----transition------> Executed

Anders Lybecker

unread,
Aug 21, 2012, 7:11:10 AM8/21/12
to dotnet-state-ma...@googlegroups.com
Hi Simon,

So the Order States (Substates) and Orderlines States (Superstates) are all part of the same state machine?

Thanks for your help.

Simon Mingaars

unread,
Aug 21, 2012, 7:35:38 AM8/21/12
to dotnet-state-ma...@googlegroups.com
That is one option. The other would be a new instance of a statemachine per order/ordeline, but you'll have to implement the dependency yourself.

Cheers,

Simon
Reply all
Reply to author
Forward
0 new messages