In Dependency Injection we program against an abstraction.
From my experience, I can state that most of the abstractions in an application have a 1:1 relationship with their implementations. This is a violation of Reused Abstraction Principle.
Mark Seeman suggested in some of his posts that we can have a Null Object Implementation for the abstractions in order to avoid RAP violation ( This suggestion from Mark Seeman could be my inference. Please correct me if I am wrong to quote Mark on this). My question here is.
Personally I find it useful to program to an abstraction even if there is only one production implementation. In particular:
Mind you, this is a false statement to start with:
In Dependency Injection we program against an abstraction.
You can use dependency injection with concrete classes perfectly easily. There's nothing to say you have to create interfaces for your dependencies. Dependency injection is more about how your class obtains its dependencies than about what level of abstraction it uses to express them.
So basically:
List<T>
- you don't need to isolate your class from the behaviour of List<T>
for test purposes, for example.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With