Design Patterns · Senior · Question 58 of 75
Two packages: checkout needs to send emails, and notifications implements email sending. Following DIP, who owns the interface?
- ✓Correct answer: The consumer (
checkout) defines the interface it needs;notificationsimplements it - 2
notificationsdefines it, andcheckoutdepends on its implementation - 3A global shared
utilspackage
Explanation
High-level policy then doesn't depend on low-level details, and implementations can be swapped or faked in tests.