Bird
Raised Fist0

How would you extend an order state machine to handle Return Requested and Returned states without breaking existing flows?

hard📝 Trade-off Q9 of Q15
LLD - Design — Online Shopping Cart

How would you extend an order state machine to handle Return Requested and Returned states without breaking existing flows?

AAllow direct transition from 'Pending' to 'Returned'
BReplace 'Delivered' state with 'Returned' state
CRemove 'Cancelled' state to simplify flow
DAdd new states and update transition table with new valid moves
Step-by-Step Solution
Solution:
  1. Step 1: Understand extension without breaking existing flows

    Adding states and updating transitions preserves old flows.
  2. Step 2: Evaluate other options

    Replacing or removing states breaks flow; direct jump is invalid.
  3. Final Answer:

    Add new states and update transition table with new valid moves -> Option D
  4. Quick Check:

    Extend by adding states and transitions [OK]
Quick Trick: Extend by adding states and transitions carefully [OK]
Common Mistakes:
MISTAKES
  • Replacing existing states
  • Removing important states
  • Allowing invalid direct transitions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes