System Design ( Day - 50 )

Manoj KumarManoj Kumar
2 min read

Design of Notification System.

Requirements
1. Plug & Play Model
2. Highly Extendible : Sms, Email, Pop-up, etc…
3. Modifiable notifications.
4. Store and log the notifications.

Design
👁 Observer Pattern — Keep Everyone in the Loop

The Observer Pattern is used to implement a publish-subscribe model.

  • NotificationObservable holds the core notification object and a list of observers.

  • Observers like Logger and NotificationEngine get notified automatically when a new notification is set.

Why? So that every component depending on a new notification update doesn’t have to manually poll for changes.

🎁 Decorator Pattern — Add Features Dynamically

The Decorator Pattern allows you to wrap notifications with extra information like timestamps or signatures:

  • SimpleNotification holds the base text.

  • TimeStampDecorator and SignatureDecorator add extra data around the content.

Why? This helps modify output without changing the original classes.

🧩 Strategy Pattern — Choose How to Notify

The Strategy Pattern is used to support multiple ways to send notifications:

  • NotificationEngine uses strategies like EmailStrategy, SMSStrategy, and PopupStrategy.

  • Each strategy has its own implementation of sendNotification.

Why? This allows the system to dynamically switch between different delivery methods based on user preference or context.

🔁 How It All Comes Together

  1. NotificationService creates and sends a notification.

  2. NotificationObservable holds and wraps the message using decorators.

  3. Observers get updated when a new notification arrives.

  4. The NotificationEngine uses the chosen strategy to send it via Email, SMS, or Popup.

0
Subscribe to my newsletter

Read articles from Manoj Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Manoj Kumar
Manoj Kumar