Design Order Status Notifications Using the Observer Pattern
Last updated: November 29, 2026
Quick Overview
Design classes so that when an order's status changes (placed, shipped, out for delivery, delivered), any number of subscribers such as email, SMS and the mobile app are notified, and new channels can be added without modifying the Order class.
Amazon
November 29, 20260
0
0 solved
Design classes so that when an order's status changes (placed, shipped, out for delivery, delivered), any number of subscribers such as email, SMS and the mobile app are notified, and new channels can be added without modifying the Order class.
An entry level object-oriented design question in the style of Amazon SDE phone screens. The interviewer checks that you decouple the subject from its listeners, validate state transitions, and keep one failing channel from blocking the others.
What the Interviewer Expects
- Define a subscriber interface with a single notify method
- Keep Order unaware of concrete channels
- Validate allowed status transitions
- Isolate failures in one subscriber
- Discuss sync vs async delivery
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- How would you make notifications asynchronous and retryable?
- How would a customer opt out of SMS for one order only?
- How would you avoid duplicate notifications on retries?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
Order has an id and status. Statuses move forward only: PLACED to SHIPPED to OUT_FOR_DELIVERY to DELIVERED, with CANCELLED allowed before SHIPPED. Subscribers can attach and detach at runtime. A subsc...
High-Level Design
OrderListenerabstract base class withon_status_change(order, old, new).Order(the subject) holds a list of listeners and an allowed transition table.update_statusvalidates, mutates, t...