Wednesday, May 09, 2012

We don't need no IoC tutorials! [um..right? Okay... yeah... well maybe a "review" wouldn't hurt... um... yeah...]

CodeProject - Inversion of Control: Overview with Examples

"Introduction

Definition: “Inversion of Control is an abstract principal describing an aspect of some software architecture design in which the flow of control of a system is inverted in comparison to procedural programming.”

What happens in procedural programming is a chunk of code that uses or consumes another chunk of code is in control of the process. It knows what piece of code, which method, in which class, it uses and this way it knows about the implementation details in the code it uses.

...

What is Dependency in terms of classes?

The example mentioned in the start of this article is an example of dependent classes. When class X uses a method of class Y or class Y as a whole, we can say that class X has some level of dependency over class Y. Dependency may extend to several levels. X uses Y, Y uses A and B, A uses C, and more. This way this chain goes on and on. The problem with this is if we have any change in these classes, it may spawn to multiple classes. The solution to this dependency problem is define a loose relation between classes. One way to achieve this is the Inversion of Control pattern. This pattern uses Dependency Injection to eliminate tight coupling between objects. Let’s see dependency with some practical example.

...

image..."

Heard of IoC/Inversion of Control but that's about it? This is a nice article that will help you wrap your head around the idea.

No comments: