I’m hearing and reading more and more about Inversion of Control (IoC) and dependency injection. The latter is basically the idea of programming only to interfaces, and not knarling up your code with factories to get concrete implementations of those, rather letting something outside of an object “inject” the implementations, prior to them being required. This injection can happen either through setter methods, or constructors. So its inverting control, hence IoC. The container controls which implementations an object gets, the object (class) is developed against interfaces. Wiring the whole lot up is an exercise for the container, based on some sort of (usually non-code based) configuration, like an XML file. IoC containers that are on my radar include Spring (not just a container btw), PicoContainer and HiveMind. Its a bit weird at first, but once you get used to it, the benefits become clear: code that is easier to evolve, everything is pluggable, and unit testing is a doddle – you can isolate units of code at a very granular level, stub everything else with test implementations (like your junit TestCase can implement all of a test targets dependencies and feed it exactly what it needs to prove some bit of functionality).
Recent Posts
Blogroll
Top Posts
- From GoDaddy to Google Apps in 20 minutes
- Automated Eclipse GUI testing the quick and simple way
- Not convinced about Guice, Spring scores again with JavaConfig
- Groovy email
- Groovy+Grails slaughters Ruby+Rails in performance stakes
- The pointless Groovy v. Ruby v. Java argument
- GMF goes on a diet for Galileo
- Impressed by GMF, but a hefty dose of patience is required
- Maven2, Java5 et al.
- Please vote for the ULTIMATE Java/Groovy/Ruby development Laptop
Archives
- November 2009
- October 2009
- June 2009
- April 2009
- January 2009
- December 2008
- November 2008
- October 2008
- August 2008
- July 2008
- June 2008
- May 2008
- March 2008
- February 2008
- January 2008
- November 2007
- October 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006
- August 2006
- July 2006
- June 2006
- May 2006
- April 2006
- January 2006
- October 2005
- September 2005
- August 2005
- June 2005
- October 2004
- June 2004
- April 2004
- January 2004
- December 2003