NotifService
- sender: EmailSender
+ notify(msg)
EmailSender
+ sendEmail(msg)
Depending on a detail
1class NotificationService {2 EmailSender sender = new EmailSender(); // concrete3 void notify(String m){ sender.sendEmail(m); }4}
Your free access ends in 7 days — and you haven’t tried it yet. Watch one algorithm run, start to finish. It takes about two minutes.
Try one problemHigh-level policy shouldn’t depend on low-level details. Point BOTH at an abstraction — and watch the dependency arrow flip.
1class NotificationService {2 EmailSender sender = new EmailSender(); // concrete3 void notify(String m){ sender.sendEmail(m); }4}
NotificationService is the high-level policy — it decides WHEN to notify.