NOTE
Dependency Inversion Principle
Dependency inversion favors interfaces over implementations and avoids direct high-level dependence on low-level details. These notes examine extensibility through that principle.
This is a historical learning note and may contain outdated or incomplete understanding.
1. What Is the Dependency Inversion Principle?
High-level modules should not depend on low-level modules.
Program to interfaces, not implementations.
2. Why Is the Dependency Inversion Principle Needed?
Improve extensibility.
3. Implementing the Dependency Inversion Principle
Each class should provide an interface or abstract class whenever possible, or both.
The declared type of a variable should be an interface or abstract class whenever possible.
No class should derive from a concrete class; it should derive from an abstract class.
When using inheritance, follow the Liskov substitution principle whenever possible.
4. References
Drag to pan, scroll to zoom, and click a node to expand or collapse it. Large maps start with deeper levels collapsed; click nodes to expand them.
Discussion
Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub