...

/

Solution: Implement a Config-Driven Notification Service Factory

Solution: Implement a Config-Driven Notification Service Factory

Use a channel-to-class map and throw on undefined keys to create a robust, extensible factory.

We'll cover the following...

Solution explanation

  • Lines 1–17: We define three interchangeable notification service classes: EmailService, SMSService, and PushService.

    • Each class exposes a .send() method, ensuring all services follow the same interface.

    • EmailService simulates sending emails, SMSService handles text messages, and PushService represents push notifications.

  • Lines 19–23: The ...