0

In an order management system for example, what's the best way to plot the states of different objects that overlap and interconnect at different states?

Example:

  1. Order object will have states like Draft, Confirmed, Placed, Picked, Delivered...etc.
  2. Invoice object will have states like Opened, Paid, Closed...etc.

Knowing that an invoice will be opened immediately when an order is "Confirmed", but the order cannot be "Placed" until the invoice is in state "Paid", the invoice from there will be closed by finance team upon checking and validating the amount, during that time, the order will proceed with its normal states without invoice being affected.

What's the proper way to plot this? One order might have multiple invoices, putting the invoice states as part of order lifecycle won't work, they have to be separate objects with separate states.

2

As Order and Invoice are distinct objects, you can't draw a single state diagram that covers them both. But one state machine can generate events that trigger transition in another state machine.

The scenario you describe can be shown in two state diagrams as

  • For the Order object:

    • In the transition from Draft to Confirmed, add an action to create an Invoice object
    • The transition from Confirmed to Placed is triggered by an event 'InvoicePaid', possibly with a guard condition that the Order is paid in full.
  • For the Invoice object:

    • The initial state is Opened (the object automatically enters this state when it is created)
    • In the transition from Opened to Paid, add an action that an event 'InvoicePaid' is sent to the creator of the object.

In addition, you could use another UML diagram, for example an Activity diagram, to show the interaction between Order and Invoice in a different view.

| improve this answer | |
  • 2
    I also find it useful to draw a collaboration diagram showing the net flow of signals between state machines. Also a sequence diagram can show the time order of signals between state machines. The key here is using the state diagram to show the life cycle of the classes involved and recognizing that it is the interactions of state machines that often yields the desired behavior. – andy mango Nov 18 '19 at 15:05
  • Thank you Bart, this is very helpful. I created two separate and put the actions + effects on each of them. – medopal Nov 19 '19 at 12:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.