Back to list
Views:   29.8K
Replies:  1

What are the benefits and dangers of IoC (Inversion of Control)?

What I find is that the Inversion of Control pattern (also called DI - Depenency Injection) is hard to grasp.

I can see the mechanics, but what problems does it try to solve?
IoC has is a lot of coding overhead, but I am not clear about the exact benefits.

A follow up question. Do you take IoC to Production or is it only for Testing?
I am asking because there is the risk of deploying incorrect xml configuration files. 
Does anyone ever talk abou this risk?
Trey Henlon, Jun 30, 2010
Reply 1
What problems does it try to solve?
  • Decoupling components and layers in the system
  • Alleviates a component from being responsible for managing it's dependencies
  • Swap dependency implementations in different environments.
  • Allows a component be tested through mocking of dependencies.
  • Provides a mechanism for sharing resources throughout an application.
  • Makes it easier to test your code. Without it, the code you are testing is hard to isolate as it will be highly coupled to the rest of the system.
  • Useful when developing modular systems. You can replace components without requiring recompilation.

Do you take IoC to Production or is it only for Testing?
I certainly use it on production as well as for testing. Note that there are DI frameworks that doesn't use Xml (Ninject be one of them).

Robert Blixt, Jul 02, 2010
Do you have an example implementation for the same? Thanks in advance.
Jul 20, 2010
Jun 07, 2010
Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Cookies       Do Not Sell       Licensing      
Made with    in Austin, Texas.  - vsn 44.0.0
© Data & Object Factory, LLC.