Inversion of Control

less than 1 minute read

Inversion of control is a pattern where the creating and life time of the objects is passed from the client to another layer.

Reasons and scenarios to use this pattern

  1. If you want to remove the dependency on a implementation.
  2. To unit test each implementation without waiting for the dependent classes.
  3. To remove the repetitive code for creating, maintaining the objects.

There are two types of Inversion

  1. Dependency Injection
  2. Service locator pattern

There are many open source containers which have implemented these patterns few e.g. are Spring.Net, Unity Container of Microsoft etc.

These patterns should be used only for a medium to large type of applications as it would have large overheads.

More information @:

Leave a comment