Skip to content
Preptima
mediumConceptDesignMidSeniorStaff

When would you use the observer pattern, and what goes wrong with it at scale?

4 min readUpdated 2026-08-15

Answer

Short answer

Observer decouples a subject from things that react to it, which is right when the subject genuinely should not know its listeners. The costs are a control flow you cannot read from the code, listener lifetimes that leak, and an exception in one observer that silently prevents the rest from running.

Mention behavioural patterns where it changes the risk, the owner, or the next check. A useful behavioural patterns point should make the answer more testable, not merely longer. Tie behavioural patterns back to the scenario so the interviewer can see why it matters here.

Was this answer helpful?

Likely follow-ups

  • One observer throws. What should happen to the other five, and who decides?
  • Why do observers leak, and what does a weak reference actually fix?
  • Should a listener be notified on the publisher's thread? What changes if not?
  • At what point would you replace an in-process observer with a message broker?

Related questions