Questions tagged [inversion-of-control]

Inversion of control (IoC) is an abstract principle describing an aspect of some software architecture designs in which the flow of control of a system is inverted in comparison to procedural programming.

In traditional programming the flow of the business logic is controlled by a central piece of code, which calls reusable subroutines that perform specific functions. Using Inversion of Control this "central control" design principle is abandoned. The caller's code deals with the program's execution order, but the business knowledge is encapsulated by the called subroutines. In practice, Inversion of Control is a style of software construction where reusable generic code controls the execution of problem-specific code. It carries the strong connotation that the reusable code and the problem-specific code are developed independently, which often results in a single integrated application. Inversion of Control as a design guideline serves the following purposes:

  • There is a decoupling of the execution of a certain task from implementation.
  • Every system can focus on what it is designed for.
  • The systems make no assumptions about what other systems do or should do.
  • Replacing systems will have no side effect on other systems.

Dependency injection and Inversion of Control are closely related. The difference between them is discussed in this question.

wikipedia: Inversion of Control

Related Patterns

137 questions
5
votes
3 answers

Missing dependencies at compile-time with IOC

Thanks to my new job, I recently discovered the inversion of control design principle (with windsor castle in C#). I really enjoy using it but something's bothering me. For me the good part about strongly typed languages is the fact that you can see…
Gatoyu
  • 161
  • 4
2
votes
1 answer

IoC, Unity and passing parameters (or a way to avoid doing so)

While the concept of IoC isn't foreign to me, I'm new to Unity and I'm having trouble connecting the metaphorical dots, so to speak. In our project we have a class library for logic, then several class libraries with repositories implementing common…
MBender
  • 273
1
vote
1 answer

Inversion of control - no "new" in a low level constructor?

When using IoC in a code base, should one always stick strictly to the pattern without exception? That means there should be no "new" in any constructor, when the newed object has dependencies. Or should one just go for convenience with that…