Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> 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

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 :)






Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: