What is the formal definition of Inversion of Control?

Possible Duplicate:
What is Inversion of Control?

I always hear Inversion of Control described in vague terms and almost always through example than a formal definition

On the one hand I hear it described in terms of objects programming to abstractions and giving up having control over explicitly instantiating a new object and it's object graph vs requesting objects that have their dependencies created injected into them runtime conditions

Then I hear it explained in terms of programming against frameworks where the programmer forfeits the flow of control in favor of coding to extension points (eg events and callbacks)

What exactly is being inverted in both cases and what do they have in common that they're equivalent examples of IoC. I've found it surprisingly difficult to find a commonly accepted definition


This is certainly a reasonable explanation:

http://en.wikipedia.org/wiki/Inversion_of_control

I own this book: I'd recommend it for good coverage of many design principles, including IoC:

Agile Principles, Patterns and Practices in C#: Martin Fowler, Micah Fowler

You might also find these links helpful:

  • DI and IOC examples in simple C#

  • Inversion of Control < Dependency Injection

  • Two pithy "explanations":

  • IoC is sometimes known as the "Hollywood Principle": Don't call us, we'll call you

  • IoC = Marriage; IOC Container = Wife

  • 链接地址: http://www.djcxy.com/p/14432.html

    上一篇: 依赖倒置原则(SOLID)与封装(OOP的支柱)

    下一篇: 什么是控制反转的正式定义?