Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you want to explore dependency injection, I'd recommend the <a href="http://ninject.org/" rel="nofollow noreferrer">Ninject</a> or <a href="http://structuremap.sourceforge.net/Default.htm" rel="nofollow noreferrer">StructureMap</a> libraries. There are quite a few StackOverflow questions <a href="https://stackoverflow.com/questions/1267567/what-should-i-consider-when-choosing-a-dependency-injection-framework-for-net">about .NET IoC containers though</a>, so just search and you'll find a lot more information.</p> <p>As for your actual question, the trend seems to be toward a <a href="http://en.wikipedia.org/wiki/Object_composition" rel="nofollow noreferrer">Composition-based</a> model, rather than a <a href="http://en.wikipedia.org/wiki/Subtyping" rel="nofollow noreferrer">Subtyping</a> one that the Provider model uses. This seems to map more closely to newer stuff coming out of Redmond, such as <a href="http://www.asp.net/mvc/" rel="nofollow noreferrer">ASP.NET MVC</a>. </p> <p>Focusing on Composition means a design outlining "has a" relationships between parts, rather than "is a" relationships. They tend to focus on defining fewer contract details and letting specific implementations deal with how to fulfill the contract, instead of the forced construction route (using abstract methods) which is common in a Subtyping-based design and often over-engineers a solution toward a specific implementation. Both approaches have drawbacks (for instance, versioning is often cited as a challenge with a Composition based design using Interfaces) so it can depend on what you're doing. </p> <p>In general, I think dependency injection is better for application code as composing your application often makes it less tightly coupled than defining a strict inheritance model and typically makes the code easier to unit test. Furthermore, a lot of the issues typically cited with composition are less important for application code than they are for frameworks (again, versioning). The truth is probably somewhere in the middle, as seen in MVC, where the dependencies between components use simple interfaces (Composition) but base classes implementing common functionality are also available to inherit and override only the necessary bits.</p> <p>That's why IoC containers tend to help here because they provide loosely coupled means for a system to ask for a component without having to know anything about the implementation. For instance, <code>DependencyResolver.GetInstanceOf&lt;IUserRepository&gt;()</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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