Design patterns·Wiring: injection, containers and lifetimes
the class asks for what it needs in its constructor and never goes looking, so a test can hand it anything.
Dependency injection
Also calledDI, injection, dependency inversion in practice
Supplying a component's collaborators from outside instead of letting it construct or locate them. It is not a framework — passing an argument is dependency injection — and the whole benefit is that the dependency becomes visible in the signature and replaceable at the call site. It is the mechanical half of dependency inversion, which is the design principle about which direction the abstraction points.