Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The best introduction to dependency injection that I've come across is actually the <a href="http://wiki.github.com/enkari/ninject/" rel="nofollow noreferrer">quick series of articles that form a walkthrough of the concepts</a> on the <a href="http://ninject.org/" rel="nofollow noreferrer">Ninject</a> wiki site.</p> <p>You haven't really given much background on what you're trying to accomplish, but it looks to me like you're trying to design a "plug-in" architecture. If this is the case - your feeling is correct - both those designs are in a word, horrible. The first one will be relatively slow (database <em>and</em> reflection?), has massive unnecessary dependencies on a database layer, and will not scale with your program, since each new class will have to be entered into the database. What's wrong with just using reflection?</p> <p>The second approach is about unscalable as it comes. Every time you introduce a new class, old code has to be updated, and something has to "know" about every object that you'll be plugging in - making it impossible for third parties to develop plugins. The coupling you add, even with something like a Locator pattern, means that your code is not as flexible as it could be.</p> <p>This may be a good opportunity to use dependency injection. Read the articles I linked. The key idea is that the dependency injection framework will use a configuration file to dynamically load the classes that you specify. This makes swapping out components of your program very simple and straightforward.</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