October 09, 2005

Dependency Injection

Jeremy D. Miller writes about The Dependency Injection Pattern; or what I've tended to call "Parameterise from above". He covers the various ways you can inject a dependency into a class rather than having the knowledge of the dependency hard wired into the class itself. I tend to favour the constructor injection pattern myself; it's all about breaking concrete coupling with interfaces and then allowing the creator of the object to specify the concrete type used by the object.

As Jeremy says, it's not just for testing; it leads to much more flexible software. It's worth following the link from Jeremy's post to Martin Fowler's "Inversion Of Control and the Dependency Injection pattern" as this is definitive coverage of the technique.


Share this entry: Email it! | bookmark it! | digg it! | reddit!

Posted by Len at October 9, 2005 11:07 PM | Comments (0) | Categories : Testing
Comments
Post a comment









Remember personal info?




Enter this code in the box below to prove that you're not some kind of automated spam robot...