Sitemap

Member-only story

LLD: Observer Pattern (Behavioral)

7 min readNov 18, 2025

--

Definition

The Observer Pattern is a behavioral design pattern where an object (aka the “subject” or “observable” or “publisher”) maintains a list of dependents (called “observers”) and automatically notifies them whenever there is a change in its state. The pattern also allows addition and removal of observers at runtime.

Press enter or click to view image in full size

Real-life Examples

Real-life examples of the Observer pattern include:

  • Weather Applications: Where multiple devices receive updates from a weather station.
  • Social Media Feeds: When we follow someone on Instagram, Facebook, or Twitter, we become observer of their profile. When they post new content, we are automatically notified.
  • Subscription Services: YouTube subscriptions, where viewers are notified of new videos, or Content magazine/newspaper/newsletter subscriptions, where publishers send new issues to subscribers.
  • Stock Market Trackers: When the price of a stock (or state) changes, the stock’s market system (the observable) sends out notifications to all interested investors (the observers).

Class Diagram

--

--

Concept && Coding - by Shrayansh
Concept && Coding - by Shrayansh

Written by Concept && Coding - by Shrayansh

Software engineer with 9+ year of experience. Java + Springboot YT: Concept && Coding - by shrayansh