Regan Russell
09/17/2017, 9:08 PMdiesieben07
09/17/2017, 9:13 PMNotificationSender
which the components of your app can use to send notifications when needed. Every component of your App creates this NotificationSender
so it can send notifications. You write a EmailNotificationSender
which sends notifications via email and use that all over your code. Now, 2 weeks later your boss asks you to send notifications via SMS instead, because he wants to receive them on the go (whatever, stupid example).
Now you have to change your whole app because you used EmailNotificationSender
everywhere.
If you use any kind of separation of concerns (dependency injection is just helping you achieve that) you only have to change this in one place:
val notificationSender = EmailNotificationSender()
becomes
val notificationSender = SMSNotificationSender()
.
But there are much better, longer and more detailed articles online 😉Regan Russell
09/17/2017, 9:14 PMRegan Russell
09/17/2017, 9:28 PMdiesieben07
09/17/2017, 9:33 PMRegan Russell
09/17/2017, 9:43 PMdiesieben07
09/17/2017, 9:46 PM