LLD - Design — Online Shopping Cart
You are designing an order state machine for an online store. The order states are Pending, Confirmed, Shipped, Delivered, and Cancelled. Which design ensures scalability and prevents invalid transitions?
Choose the best approach:
- Use a dictionary mapping each state to allowed next states.
- Hardcode all transitions in if-else blocks.
- Allow any state to transition to any other state.
- Use a single variable without validation.
