Skip to main content
PreparationZone Logo
PrepZone

Observer Pattern

Decouple event sources from listeners.

Pass checkpoint below

Read these first

Why this matters

  • Subject/observer — detailed pointwise breakdown in the section below.
  • Push vs pull — detailed pointwise breakdown in the section below.
  • CampusOS seat alerts — detailed pointwise breakdown in the section below.
  • Memory leaks — detailed pointwise breakdown in the section below.
  • Patterns are forces and solutions — name the force before the pattern.
SubjectnotifyObservers()
Observer A
Observer B
Observer C
Subject notifies subscribers when state changes — decouples publishers from listeners.

Overview

Decouple event sources from listeners. Study each section below in order — every list is interview-ready reference material.

Subject/observer

Points to cover

  • Definition — what Subject/observer means in one clear sentence
  • When to use — the force or smell that triggers this concept
  • CampusOS example — where this appears in parking, booking, or library modules
  • How to explain — pointwise bullets you can say aloud in an interview
  • Common mistake — what weak candidates do instead
  • Refactor move — one concrete change that improves the design

The rest of this guide is part of Pro

Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.

Still to come · 3 sections

  • Push vs pull
  • CampusOS seat alerts
  • Memory leaks

Test yourself

Answer these before moving on — recall is what makes it stick.