Order Management System - State Pattern Implementation
This is an implementation of the State design pattern for an e-commerce Order Management System. By utilizing this pattern, an order dictates its own lifecycle (Created, Paid, Shipped, Delivered) and strictly enforces business rules without relying on messy if/else or switch statements evaluating an "order status" flag.
Problem Statement
Building the backend flow for an e-commerce order that transitions through four sequential states: Created, Paid, Shipped, and Delivered. The challenge is ensuring that illegal operations—like attempting to ship an unpaid order or paying for an order that has already been delivered—are gracefully blocked based on the current state.
Key Challenge:






