Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I don't think you're going to get an authoritative answer on this one because the term "IoC" is kind of overloaded and to say "the one true meaning of IoC is..." is kind of pedantic. But I'll share my opinion anyway :)</p> <p><strong>Dependency Inversion</strong> is about depending on an abstraction. Consider a <code>HelloWorld</code> class that depends on an <code>IStringWriter</code>, and an implementation class <code>ConsoleStringWriter</code>.</p> <p><strong>Inversion of Control</strong> is when the framework/infrastructure invokes application code, rather than the other way around. For example, when a user closes a WPF app, you don't call the framework, it <a href="http://msdn.microsoft.com/en-us/library/system.windows.application.exit.aspx" rel="nofollow noreferrer">raises an event</a> that you can subscribe to.</p> <p><strong>They are often combined.</strong> For example, Hibernate depends on the abstraction defined by <a href="http://ajava.org/online/hibernate3api/org/hibernate/Interceptor.html" rel="nofollow noreferrer">its Interceptor interface</a> in order to implement IoC. From an Interceptor's point of view, control is inverted - Hibernate calls the Interceptor. Another example you see all over is <code>IHandle&lt;T&gt;</code> where T is an Event or a Command or a Message - the infrastructure calls the handler at the right time.</p> <p>Its confusing because we call them "IoC containers", but you can do DI without doing IoC. If you inject a <code>ConsoleStringWriter</code> into a <code>HelloWorld</code> I don't really think of this as IoC because there is no "framework" or "infrastructure". But that's because Hello World is trivial - as an application becomes more complex the need for IoC increases.</p> <p>See also <a href="https://stackoverflow.com/questions/3226605/inversion-of-control-dependency-injection">this question</a> and accepted answer.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload