1. When would you introduce a State Machine diagram for an e-commerce order, and what benefits does it add?
Introduce it when the lifecycle is complex and errors are costly. It makes allowed transitions explicit and highlights guards such as “payment captured” before shipping. This reduces invalid state hops, improves tests, and informs compensating actions for failures and refunds.
Pending -> Paid -> Shipped -> Delivered Invalid: Shipped -> Pending (guard prevents)