...
/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...
We'll cover the following...
Solution explanation
Lines 1–17: We define three interchangeable notification service classes:
EmailService,SMSService, andPushService.Each class exposes a
.send()method, ensuring all services follow the same interface.EmailServicesimulates sending emails,SMSServicehandles text messages, andPushServicerepresents push notifications.
Lines 19–23: The ...