Object-Oriented Programming · Amazon · Medium
Aggregate Cart with Immutable Pricing Snapshots Intuition The cart is modeled as an aggregate root: it owns line-item creation, quantity changes, and removal. External code never mutates the cart's lines directly. Instead, checkout and pricing logic read an immutable CartSnapshot. Pricing rules are separate pure objects that consume that snapshot and return adjustments. This separation keeps evolving promotion behavior out of the cart's mutation path. The critical rule is…
Checking your access…