3 ms·
> I'll make the connection object a parameter rather than have the method set up the connection itself Parameter (Dependency) Injection. > I might make the co
by hammerdr 16y ago
> I'll make the connection object a parameter rather than have the method set up the connection itself
Parameter (Dependency) Injection.
> I might make the connection object a parameter to the constructor
Constructor (Dependency) Injection.
> construct it in a helper method that I can override for testing purposes.
Not DI.
http://martinfowler.com/articles/injection.html http://martinfowler.com/articles/injection.html
Edit:
For languages such as Java and C#, wiring up these objects is quite a pain.
For duck typed languages such as Python and Ruby, it isn't that big of a pain. So we just do it. Just because you don't have an IoC framework doesn't mean you aren't practicing DI :)
- rimantas 16y agoRelevant, I guess: http://onestepback.org/articles/depinj/index.html http://onestepback.org/articles/depinj/index.html