Bird
0
0

You need to design an order tracking state machine that handles normal flow and exceptions like cancellation and returns. Which design approach best ensures scalability and clarity?

hard📝 Trade-off Q15 of 15
LLD - Design — Food Delivery System
You need to design an order tracking state machine that handles normal flow and exceptions like cancellation and returns. Which design approach best ensures scalability and clarity?
AModel states hierarchically with sub-states for exceptions and normal flow
BUse a single flat state list with many transitions for all cases
CHandle exceptions outside the state machine with separate logic
DUse only two states: 'active' and 'closed' to simplify design
Step-by-Step Solution
Solution:
  1. Step 1: Understand complexity of order states

    Orders have normal states (placed, shipped, delivered) and exceptions (cancelled, returned) which can be grouped logically.
  2. Step 2: Evaluate design approaches for scalability and clarity

    Hierarchical states allow grouping related states, reducing complexity and improving maintainability compared to flat or oversimplified models.
  3. Final Answer:

    Model states hierarchically with sub-states for exceptions and normal flow -> Option A
  4. Quick Check:

    Hierarchical states = scalable and clear [OK]
Quick Trick: Group related states hierarchically for clarity and scale [OK]
Common Mistakes:
  • Using flat states causing many transitions
  • Ignoring exceptions in state machine
  • Oversimplifying states losing detail

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes