This project demonstrates the implementation of key design patterns in C#, focusing on a notification system. The system allows users to send notifications via Email or SMS, utilizing various design patterns to ensure maintainability and scalability.
- Singleton Pattern → Ensures a single instance of the
UserList
class, managing a shared user list. - Factory Pattern → Dynamically creates notification senders (
Email
orSMS
). - Facade Pattern → Provides a simple interface (
NotificationFacade
) to handle complex notification logic. - Observer Pattern → Notifies multiple users when a message is sent.
📂 DesignPatterns-main
├── 📄 Program.cs # Main entry point of the application
├── 📄 Singleton.cs # Singleton pattern implementation
├── 📄 FactoryDesign.cs # Factory pattern implementation
├── 📄 FacadeDesign.cs # Facade pattern implementation
├── 📄 ObserverDesign.cs # Observer pattern implementation
├── 📄 NotificationApp.csproj # Project file
├── 📄 NotifucationApp.sln # Solution file
- .NET SDK installed (version 6 or later)
- Clone the repository:
git clone https://github.com/your-username/DesignPatterns.git cd DesignPatterns-main
- Build the project:
dotnet build
- Run the project:
dotnet run
- Enter the notification mode (
email
orsms
), then provide a subject and body.
- User Input: The program asks the user to select a notification mode (
email
orsms
). - Factory Pattern: The system dynamically creates the required sender (Email/SMS) using
FactoryofNotificationSendType
. - Facade Pattern:
NotificationFacade
simplifies the process of fetching user data (via Singleton) and sending notifications. - Observer Pattern: The system notifies all subscribed users when a message is sent.
Enter Notification sending mode (email/sms): email
Enter Subject: Meeting Reminder
Enter Body: Meeting at 5 PM
Selected Mode is Email and is sent to: Neeraj Yadav - Meeting Reminder - Meeting at 5 PM
Selected Mode is Email and is sent to: Ajeet Kumar - Meeting Reminder - Meeting at 5 PM
...
Feel free to fork this repository and submit pull requests with improvements.
This project is licensed under the MIT License. See LICENSE
for details.