Search code examples
emaildesign-patternspush-notificationnotifications

What design-pattern I should use in my notification system?


Which design-pattern I should use in this case:

  • I have a rest API notification system.
  • I can notify by Email
  • notify by push;
  • notify by WhatsApp.
  • And I want to implement more technologies, and I do not want to modify the core, I want to add only modules to the system. For example, adding Telegram Messages, Twitter messages, or another email provider.

    Any recommendation?


    Solution

  • According to your problem statement, two different types of design patterns will be involved:

    1. Strategy Pattern: It will define the notification strategy based on the contexts like email, push, whatsapp, etc.

    2. Observer Pattern: It will perform the publisher and subscribers operation with the behavior of loose coupling. It will automatically notify to subscribers.

    You can also integrate RabbitMq somewhere for queuing and on time pushing messages.