I have a question… what problems does dependency injection solve that
duck typing does not?
As Rubyists we can compose in such a way that we expect objects which
a certain protocol. The method protocol in use becomes a kind of
abstraction, allowing us to swap in other types of objects which quack
same, but may be completely different objects of a completely different
class with a completely different implementation.
Dependency injection seems like myriad complexity in order to solve a
problem that Ruby already solves by the very nature of its type system.
have used this sort of approach to simply compose the kinds of systems I
can’t fathom being able to build in statically typed languages.
So all that said, what does dependency injection offer Rubyists that
typing does not?