Design Patterns interview question · Most asked

Scenario: when an order is placed, several systems (email, inventory, analytics, loyalty) must react, and more will be added. How do you design it?

Create a free account to save this page, take notes and track your progress. Sign in

Summary

Publish an OrderPlaced event and let each system subscribe: Observer in-process, or Pub/Sub through a broker if the reactions are slow, unreliable or in other services. Order placement no longer knows its consumers.

Longer Answer

With a broker (SQS/SNS, Kafka, RabbitMQ), use the transactional outbox pattern so the event is published only if the order is committed, make subscribers idempotent (at-least-once delivery), and add dead-letter queues. In-process observers are fine for fast, reliable reactions in a monolith.

Key Points

  • Event + subscribers.
  • Observer in-process, Pub/Sub across services.
  • Outbox for reliable publishing.
  • Idempotent subscribers and DLQs.

Deep dive: Design Patterns, Explained Simply: Pub/Sub and the Event Bus

Explanation

What interviewers look for

Decoupling plus reliability concerns (outbox, idempotency).

More most-asked Design Patterns questions

← All Design Patterns questions

Was this page helpful?