dependency-inversion
Installation
SKILL.md
Dependency Inversion Principle
When to use
- The user wants a class to depend on an interface rather than a concrete implementation so the two can vary independently.
- The user wants collaborators injected through the constructor instead of being created with
newinside a class. - The user wants to substitute a fake or mock for a dependency in a test without editing the class under test.
When NOT to use
- Do not add an interface for a small internal helper that has one caller, no I/O, and no realistic second implementation.
- Do not invert a dependency on a stable standard-library type or a pure value (a string, a DateTimeImmutable, an array helper).