Mocking Dependencies With Generics
Elmar Kretzer (via Andy Bargh):
You can inject code dependencies in a transparent way by using generics and
typealias.[…]
Those dependencies are loosely coupled, but in my opinion they belong together in a semantic way.
[…]
We end up with:
- a generic
ModelFortaking a type conforming toEnvironment- a typealias
ModelrepresentingModelFor<RealWorld>- no code necessary to manage the dependencies with properties or whatever