System Design ( Day - 50 )

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
andNotificationEngine
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
andSignatureDecorator
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 likeEmailStrategy
,SMSStrategy
, andPopupStrategy
.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
NotificationService
creates and sends a notification.NotificationObservable
holds and wraps the message using decorators.Observers get updated when a new notification arrives.
The
NotificationEngine
uses the chosen strategy to send it via Email, SMS, or Popup.
Subscribe to my newsletter
Read articles from Manoj Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
