문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 softwareengineering.stackexchange
scroll top