Skip to content
Preptima
mediumDesignCodingMidSenior

Design the classes for a notification service that sends email, SMS and push. Which design patterns earn their place, and which would you leave out?

Name what varies first: channel, text, the user's channel choices and retry. A notification service then needs a channel interface (a strategy) picked from a registry, templates as data, a preference policy and a retry policy splitting transient from permanent errors. Most other design patterns add classes, not value.

6 min readUpdated 2026-10-10

Answer

Short answer

Start with what varies, not with a pattern list. A notification service varies along four axes: the channel (email, SMS, push), the text for each notification type, which channels a given user wants, and how failed sends are retried. Each axis gets one small abstraction. A Channel interface is the strategy pattern, picked from a registry keyed by channel type. Templates are data, preferences are a policy object, and retry is a separate policy. Design patterns beyond that usually add classes without removing a problem, and saying which ones you left out is part of the answer.

Was this answer helpful?

Likely follow-ups

  • The SMS provider times out after it may have delivered the message. Do you retry, and what decides it?
  • Marketing wants a quiet-hours rule per user time zone. Which class changes, and which must not?
  • How would you add a second SMS provider for failover without touching the code that chooses channels?
  • A user unsubscribes from push while a retry for that push is still queued. What happens to the retry?

Related questions

Related Topics