Dependency Injection Inversion 304

Posted by Uncle Bob Sun, 17 Jan 2010 18:42:00 GMT

Dependency Injection is all the rage. There are several frameworks that will help you inject dependencies into your system. Some use XML (God help us) to specify those dependencies. Others use simple statements in code. In either case, the goal of these frameworks is to help you create instances without having to resort to new or Factories.

I think these frameworks are great tools. But I also think you should carefully restrict how and where you use them.

Consider, for example, this simple example using Google’s Guice framework.


 public class BillingApplication {
   public static void main(String[] args) {
    Injector injector = Guice.createInjector(new BillingModule());
    BillingService billingService = injector.getInstance(BillingService.class);
    billingService.processCharge(2034, "Bob");
  }
 }

My goal is to create an instance of BillingService. To do this, I first get an Injector from Guice. Then I use the injector to get an instance of my BillingService class. What’s so great about this? Well, take a look at the constructor of the BillingService class.


class BillingService {
  private CreditCardProcessor processor;
  private TransactionLog transactionLog;

  @Inject
  BillingService(CreditCardProcessor processor, TransactionLog transactionLog) {
    this.processor = processor;
    this.transactionLog = transactionLog;
  }

  public void processCharge(int amount, String id) {
    boolean approval = processor.approve(amount, id);
    transactionLog.log(
      String.format("Transaction by %s for %d %s",
      id, amount, approvalCode(approval)));
  }

  private String approvalCode(boolean approval) {
    return approval?"approved":"denied";
  }
}

Oh ho! The BillingService constructor requires two arguments! A CreditCardProcessor and a TransactionLog. How was the main program able to create an instance of BillingService without those two arguments? That’s the magic of Guice (and of all Dependency Injection frameworks). Guice knows that the BillingService needs those two arguments, and it knows how to create them. Did you see that funky @Inject attribute above the constructor? That’s how it got connected into Guice.

And here’s the magic module that tells Guice how to create the arguments for the BillingService


public class BillingModule extends AbstractModule {
  protected void configure() {
    bind(TransactionLog.class).to(DatabaseTransactionLog.class);
    bind(CreditCardProcessor.class).to(MyCreditCardProcessor.class);
  }
}

Clever these Google-folk! The two bind functions tell Guice that whenever we need an instance of a TransactionLog it should use an instance of DatabaseTransactionLog. Whenever it needs a CreditCardProcessor it should use an instance of MyCreditCardProcessor.

Isn’t that cool! Now you don’t have to build factories. You don’t have to use new. You just tell Guice how to map interfaces to implementations, and which constructors to inject those implementations in to, and then call Injector.getInstance(SomeClass.class); and voila! You have your instance automatically constructed for you. Cool.

Well, yes it’s cool. On the other hand, consider this code:


public class BillingApplicationNoGuice {
  public static void main(String[] args) {
    CreditCardProcessor cp = new MyCreditCardProcessor();
    TransactionLog tl = new DatabaseTransactionLog();
    BillingService bs = new BillingService(cp, tl);
    bs.processCharge(9000, "Bob");
  }
}

Why is this worse? It seems to me it’s better.

But Uncle Bob, you’ve violated DIP by creating concrete instances!

True, but you have to mention concrete instances somewhere. main seems like a perfectly good place for that. Indeed, it seems better than hiding the concrete references in BillingModule.

I don’t want a bunch of secret modules with bind calls scattered all around my code. I don’t want to have to hunt for the particular bind call for the Zapple interface when I’m looking at some module. I want to know where all the instances are created.

But Uncle Bob, You’d know where they are because this is a Guice application.

I don’t want to write a Guice application. Guice is a framework, and I don’t want framework code smeared all through my application. I want to keep frameworks nicely decoupled and at arms-length from the main body of my code. I don’t want to have @Inject attributes everywhere and bind calls hidden under rocks.

But Uncle Bob, What if I want to get an instance of BillingService from deep in the bowels of my application? With Guice I can just say injector.getInstance(BillingService.class);.

True, but I don’t want to have createInstance calls scattered all through my code. I don’t want Guice to be poured all over my app. I want my app to be clean, not soaked in Guice.

But Uncle Bob, That means I have to use new or factories, or pass globals around.

You think the injector is not a global? You think BillingService.class is not a global? There will always be globals to deal with. You can’t write systems without them. You just need to manage them nicely.

And, no, I don’t have to use new everywhere, and I don’t need factories. I can do something as simple as:


public class BillingApplicationNoGuice {
  public static void main(String[] args) {
    CreditCardProcessor cp = new MyCreditCardProcessor();
    TransactionLog tl = new DatabaseTransactionLog();
    BillingService.instance = new BillingService(cp, tl);

    // Deep in the bowels of my system.
    BillingService.instance.processCharge(9000, "Bob");
  }
}

But Uncle Bob, what if you want to create many instances of BillingService rather than just that one singleton?

Then I’d use a factory, like so:


public class BillingApplication {
   public static void main(String[] args) {
    Injector injector = Guice.createInjector(new BillingModule());
    BillingService.factory = new BillingServiceFactory(injector);

    // Deep in the bowels of my code.
    BillingService billingService = BillingService.factory.make();
    billingService.processCharge(2034, "Bob");
  }
}

But Uncle Bob, I thought the whole idea was to avoid factories!

Hardly. After all, Guice is just a big factory. But you didn’t let me finish. Did you notice that I passed the Guice injector into the factory? Here’s the factory implementation.


public class BillingServiceFactory extends AbstractModule {
  private Injector injector;

  public BillingServiceFactory(Injector injector) {
    this.injector = injector;
  }

  protected void configure() {
    bind(TransactionLog.class).to(DatabaseTransactionLog.class);
    bind(CreditCardProcessor.class).to(MyCreditCardProcessor.class);
  }

  public BillingService make() {
    return injector.getInstance(BillingService.class);
  }
}

I like this because now all the Guice is in one well understood place. I don’t have Guice all over my application. Rather, I’ve got factories that contain the Guice. Guicey factories that keep the Guice from being smeared all through my application.

What’s more, if I wanted to replace Guice with some other DI framework, I know exactly what classes would need to change, and how to change them. So I’ve kept Guice uncoupled from my application.

Indeed, using this form allows me to defer using Guice until I think it’s necessary. I can just build the factories the good old GOF way until the need to externalize dependencies emerges.

But Uncle Bob, don’t you think Dependency Injection is a good thing?

Of course I do. Dependency Injection is just a special case of Dependency Inversion. I think Dependency Inversion is so important that I want to invert the dependencies on Guice! I don’t want lots of concrete Guice dependencies scattered through my code.

BTW, did you notice that I was using Dependency Injection even when I wasn’t using Guice at all? This is nice and simple manual dependency injection. Here’s that code again in case you don’t want to look back:



public class BillingApplicationNoGuice {
  public static void main(String[] args) {
    CreditCardProcessor cp = new MyCreditCardProcessor();
    TransactionLog tl = new DatabaseTransactionLog();
    BillingService bs = new BillingService(cp, tl);
    bs.processCharge(9000, "Bob");
  }
}

Dependency Injection doesn’t require a framework; it just requires that you invert your dependencies and then construct and pass your arguments to deeper layers. Consider, for example, that the following test works just fine in all the cases above. It does not rely on Guice, it only relies on the fact that dependencies were inverted and can be injected into BillingService


public class BillingServiceTest {
  private LogSpy log;

  @Before
  public void setup() {
    log = new LogSpy();
  }

  @Test
  public void approval() throws Exception {
    BillingService bs = new BillingService(new Approver(), log);
    bs.processCharge(9000, "Bob");
    assertEquals("Transaction by Bob for 9000 approved", log.getLogged());
  }

  @Test
  public void denial() throws Exception {
    BillingService bs = new BillingService(new Denier(), log);
    bs.processCharge(9000, "Bob");
    assertEquals("Transaction by Bob for 9000 denied", log.getLogged());    
  }
}

class Approver implements CreditCardProcessor {
  public boolean approve(int amount, String id) {
    return true;
  }
}

class Denier implements CreditCardProcessor {
  public boolean approve(int amount, String id) {
    return false;
  }
}

class LogSpy implements TransactionLog {
  private String logged;

  public void log(String s) {
    logged = s;
  }

  public String getLogged() {
    return logged;
  }
}

Also notice that I rolled my own Test Doubles (we used to call them mocks, but we’re not allowed to anymore.) It would have been tragic to use a mocking framework for such a simple set of tests.

Most of the time the best kind of Dependency Injection to use, is the manual kind. Externalized dependency injection of the kind that Guice provides is appropriate for those classes that you know will be extension points for your system.

But for classes that aren’t obvious extension points, you will simply know the concrete type you need, and can create it at a relatively high level and inject it down as an interface to the lower levels. If, one day, you find that you need to externalize that dependency, it’ll be easy because you’ve already inverted and injected it.

Comments

Leave a response

  1. Avatar
    Ben 41 minutes later:

    Of course Guice looks like overkill for and example with 2 dependencies and a single scope/lifetime. What happens if some of the dependencies need be created per HttpRequest, some are created new each time and some are singletons? Are you going to write a factory for each scope?

  2. Avatar
    Mark Seemann about 1 hour later:

    Fortunately, I hardly consider this post controversial. In my book, DI is simply a set of patterns and principles that describe how we can write loosely coupled code. These include the GoF principle of programming to interfaces, as well as patterns such as Constructor Injection.

    DI simply describes how you organize classes and turn their dependencies into invariants.

    How you decide to wire up those dependencies in the end are much less important. You can use Poor Man’s DI (as you show in one of your Main examples), or you can use a DI Container (in .NET, most DI Containers don’t require you to put attributes or other explicit things in the code to work).

    The Hollywood Principle is very applicable to DI: Don’t call the DI Container, it’ll call you.

    The best approach is to let the container wire up the desired object graph in the application’s entry point and then get out of the way. I call this place the Composition Root.

    The idea is to keep the application code completely Container-agnostic.

    In summary, I agree :)

  3. Avatar
    Sam Newman about 1 hour later:

    Yeah – my view on IOC/DI for years has been that using a DI framework is something I consider down the line, but my starting point is wiring by hand.

    BTW, I would not consider creating concrete instances to be a violation of DIP (not that I would care about it violating some rule anyway if I thought that it was the right solution) – not when the instances are then just being provided to the class that will use them.

    Like the previous commentator, I do find DI frameworks useful for things like lifecycle management (even then their not essential), and for the fact that they can remove the need for some boiler-plate wiring code.

    Personally, I prefer Pico to Guice – why on earth did they think @inject was a good idea when a class only has one constructor?

  4. Avatar
    Geir about 1 hour later:
    You just tell Guice how to map interfaces to implementations, and which constructors to inject those implementations in to, and then call Injector.getInstance(SomeClass.class);

    Can I suggest changing the example code to Injector.getInstance(SomeInterface.class) in your post? I have had to spend hours with some people explaining how DI gets you from an interface to an implementation, and the process seemed easier when I clearly separated what was interfaces and implementations in my examples.

    Personally, I really like the annotations used by Spring. I can declare a class to be a service by annotating the class with a @Service annotation. The service gets injected in a similar manner to what you show with Guice.

    The only explicit configuration I need to do outside of my services is where I have multiple service implementations around, which I wouldn’t usually have. I really like this because it mostly does away with the need of having wiring of dependencies in a separate entity – main methods or xml files. All configuration is local to the service or the consumer of the service – and it is possible to make tooling that lets you move from one to the other.

  5. Avatar
    Gil Zilberfeld about 1 hour later:

    I like how you managed to put all the Guice stuff inside a factory. I do expect, though, that in a real application, with multiple factories for different object, it would become a bit messy. But it’s concentrated mess.

    I have to ask – when do you consider moving from hand written test doubles to a framework? And where in a TDD process would you decide that?

    Gil Zilberfeld

    Typemock

  6. Avatar
    Neil Mosafi about 1 hour later:

    The only place that should have reference to the container should be the bootstrapping code (main in your case). I would not use any container that requires otherwise.

  7. Avatar
    Sven Efftinge about 2 hours later:

    Yes, an injector is a factory, but it will usually only be called once per application. The rest is wired and has no dependency to the injector. No serious Guice user will use the injector directly in order to obtain some object.

    The problem is not the factory or the new operator but the static dependency. You should know that as a TDD friend.

    And, yes , you can’t get rid of globals completely, but you can get rid of many dependencies to them. Stating that one should give up on removing them, because you can’t get rid of them completely is IMHO very questionable.

  8. Avatar
    Darren Gilroy about 2 hours later:

    But Uncle Bob, what if CreditCardProcessor has two dependencies, and DatabaseTransactionLog has two dependencies, and each of those has two dependencies… (Remember the Faberge Shampoo commercial?)

    You suggest we can create instances at a relatively high level and inject them down as an interfaces to the lower levels, but I contend that as the graph gets larger that quickly becomes unwieldy.

    The point of Guice (and similar tools) is not to avoid factories, instead it fills the role of one-big-factory so you don’t have to. From my perspective, Guice exactly supports the role/spirit/purpose of GOF factories, just with less ceremony.

  9. Avatar
    Uri Goldstein about 2 hours later:

    Hi Uncle Bob,

    As much as I appreciate your thoroughness, wasn’t this post a bit too long? :)

    To the point – The way you’re using DI here really is quote awful – just like you say yourself. DI should be used more carefully and with component oriented programming in mind.

    One of the most important principles is to decouple the application from the specific DI container. Your classes need to be “DI free” in that no special attributes are present and no direct calls are made to DI container instances.

    Ideally IMHO, the container really should only be used only on bootstrapping to initially weave the components together.

    You can have both the flexibility of DI with only a minimal impact on code readability and maintain independence from tightly coupled containers and their meta data.

  10. Avatar
    Jason Snelders about 3 hours later:

    Uncle Bob, thanks for the wonderful post. I don’t always agree with what you have to say (and that’s a good thing) but this one I thin hit the nail succinctly and elegantly on the head.

  11. Avatar
    Derek Greer about 6 hours later:

    Thanks for the post Uncle Bob. While I appreciate your desire for simplicity by minimizing your reliance on DI and mocking frameworks, the example set forth here falls short in highlighting either the real benefits or faults of DI containers (I know, you said you hate the name container, but that’s what everyone calls them so if you are going to say fake vs. mock because of that then …).

    One issue in this example is in your presumption of how DI frameworks are generally used. I think it’s important to draw a distinction between Dependency Injection and the Service Locator pattern here. Dependency Injection is the process of separating the concerns of acquiring dependencies from an object, while the Service Locator pattern merely provides a layer of indirection for acquiring dependencies (not necessarily performing any injection on the object being obtained). While I’ve found that newcomers do tend to gravitate toward using containers directly as a service locator, the container should generally only ever be referenced in an application’s bootstrapping related components, or at most in module or application level controllers. An application can generally be designed to have all dependencies resolved through the container with minimal infrastructure coupling to the actual DI framework.

    Another issue is that your example only demonstrates dependency injection with a two-level object graft. It fails to highlight the strengths of a DI container with more typical scenarios, or the weaknesses of the manual approach you advocated.

  12. Avatar
    Dean Wampler about 8 hours later:

    For most needs, I now use Scala’s “self types” and traits to accomplish the goals of DI/IoC using Scala code itself, rather than a separate framework:
    http://programming-scala.labs.oreilly.com/ch13.html#DependencyInjectionInScala

  13. Avatar
    Esko Luontola about 8 hours later:

    “I have to ask – when do you consider moving from hand written test doubles to a framework? And where in a TDD process would you decide that?”

    In my case, the point where I started using Guice the first time was when it was time to implement a request scope in the application. Implementing scopes with hand-written factories would have been very complicated, but with Guice it was easy. At that point the project had about 2000 SLOC production code (77 .java files) and 3000 SLOC test code. Creating a custom request scope (and the application’s subsystem which is based on scopes), annotating existing classes with @Inject and writing the Guice modules took in total 4 hours.

    This experience showed me that manual DI can get you quite far, and then when the dependencies get complex enough or you need some other features of a DI container, adding a DI container to the project is quick and easy.

    “No serious Guice user will use the injector directly in order to obtain some object.”

    True, unless you need to inject instances which are created by some other system. I’ve had one situation where the Injector had to be used directly: some Java objects are deserialized from a database and they need to have some runtime dependencies injected. This means that when the objects are deserialized, they are passed to Injector.injectMembers() – that is done by a tiny class that does nothing else than hold the injector and is completely decoupled from the rest of the application.

    And even in that case the use of Injector could have been avoided by hard coding that which class requires which dependency (there are only one or two classes which require this special handling), although using the Injector keeps the system more decoupled (if the injectMembers() call proves to be slow, then hard coding it is a potential performance optimization).

    “You think the injector is not a global?”

    You can have multiple injectors in the same JVM, even within the same application, and they will not know anything about each other – if the application is structured well, they will not even be able to get access to each other even if they tried. When an injector is not anymore used, it will be garbage collected from the memory.

    The injector is not a global variable, unlike the horrible mutable static BillingService.instance/factory field. (Such fields are usually needed only temporarily, when incrementally refactoring a large Service Locator based application to use DI.)

    Like others have said, a DI example with just 3 classes can not be used to discuss the pros and cons of manual DI vs. container-assisted DI. You’ll need an example (a real application) with tens or hundreds of classes to discuss the benefits of container-assisted DI.

  14. Avatar
    Jesse Wilson about 13 hours later:

    Yes, it is possible to do DI by hand. And in small applications, the amount of code required to construct objects is comparable. But for multiple-developer applications, you’ll write less code if you use a framework.

    Before you abandon Guice, consider a few things that your post has overlooked…

    Lazy initialization via Providers. Wherever you want you can defer initialization of a dependency by injecting a Provider rather than a Foo. Doing this with by-hand DI is possible, but your code size will blow up significantly. Particularly since you’ll need to rewrite every path that uses a given dependency.

    HTTP sessions and request scoping. Without a framework, working with session objects is ugly. You need to think about concurrency, mapping keys to values, and casting. Guice takes care of all of this for you with just an annotation: @SessionScoped.

    Modularity. You can reuse Guice modules across applications. The module is a unit of encapsulation, and no single piece of code needs to know the implementation classes of multiple modules.

  15. Avatar
    J. B. Rainsberger about 14 hours later:

    Holy shit, Bob, is this what you see actual programmers doing? They’re inverting the dependencies, all right, but apparently for fun and not for profit.

    As I understand the DIP, we benefit from pushing the decisions about which implementations to choose for our interfaces up towards the entry point. At the entry point, we make as many of those decisions as possible, creating a graph of loosely-coupled objects that request services primarily through abstractions. Then we invoke go() and magic happens. As I teach design, our goal is to wrangle all those pesky “new” calls into a single place, so we no longer need crazy things like Singletons and the only Factories we need are Abstract Factories, which have a real purpose, rather than just confusing people learning how to depend on more abstractions.

    I might just have to riff on this later. Thanks.

  16. Avatar
    Pablo about 16 hours later:

    Interesting. Your point is that by overusing DI frameworks, we are creating an application that has a heavy dependency on them, which we need to invert.

    I like the idea of using the factory to encapsulate the framework, very interesting post.

  17. Avatar
    Indrit Selimi about 16 hours later:

    Yes, Guice is framework…yet an elegant and rigorous Dependency Injector implementor. The problem is that too many people confuses the dependency injection paradigm with the framework of the moment, too many people thinks that Pico, Guice, Spring and DI are the same thing… Manual DI is perfect for small projects!

    An injector is automation tool for wiring dependencies and in the case of Guice this is done rigorously following the DI concepts (key, scope,... etc); I see no problem with this approach.

    - “I don’t want a bunch of secret modules with bind calls scattered all around my code” There are no secrets, simply there is a “declarative way” wiring implementor without using an external language like xml and having a compile time check capability. Probably only in the “main” method the dependency are “hidden”, in the rest of the code the Dependency Inversion Principle predominates. Said that , I will add that the Guice module code is part of the production code so everybody must know in which way the dependencies are wired (in the same way if the wiring was done by hand in a “application factory”).

    - “I don’t want to write a Guice application.” Nor do I, who said that having some annotations (dependency keys) on my code that means that is automatically a Guice Application? (I have many other type of annotations on my code…)

    - You think the injector is not a global? Yes I think so, at least not in the evil sense. Remember that we are not speaking about globals on business logic… Scope is an VERY IMPORTANT dependency injection concept that Guice, Spring etc implements. (also you can have different injectors in the same application if you prefer).

    - “After all, Guice is just a big factory” I think that this definition is too simplistic, it doesn’t address important DI concepts like keys, scope, lifecycle … I would add also that it is “boiler plate code”-less automatic factory.

    -“if I wanted to replace Guice with some other DI framework” No problem, the classes are written in DI style mode declaring dependencies following DIP, Guice doesn’t matters.

    I strongly agree that speaking of DI doesn’t mean speaking of a particular framework but everybody must study well the DI own concepts! Starting to write DI by hand is a good starting point for understanding its concepts and some constructs used by Guice (like Provider) are very useful.

  18. Avatar
    Roy van Rijn about 16 hours later:

    The problem is that most JEE applications have their entry-point defined in the web.xml as servlet/filter. From that point you need a factory to retrieve your dependencies. Even if you use some web framework, you still need a factory (or DI-plugin) to get to your dependencies.

    And once you need a factory its almost always easier to use a DI-framework. Because all DI-frameworks have a factory build-in, but can also wire the dependencies for you.

    The other big advantage of using a DI-framework is that everybody in larger projects will manage their classes in a similair way. This will help maintainability and extendibility.

    But I have to agree on the concept DI being confused with DI-frameworks. I’ve seen a lot of times, people using something like Spring or Guice without really understanding the pattern. This is very bad! I, myself, give Spring courses to collegues, and the first thing I teach them is to write their own “Spring”, their own dependency injection code.

    First I present them with some unmanaged code and ask them to write a unit-test. Of course this can’t be done because the service itself creates the layers below. They don’t have a way to replace the dependencies, so no way to use stubs/mocks. After that I show them how to write/use a factory, and then I show them how to use the DI-pattern… And finally we use Spring as a generic DI-solution.

  19. Avatar
    MM about 20 hours later:

    - “I don’t want a bunch of secret modules with bind calls scattered all around my code.”

    So don’t scatter them. Put them all one place.

    - “I don’t want lots of concrete Guice dependencies scattered through my code.”

    I agree with this. I first learned about DI containers in the .NET world and when I saw that Guice requires constructors to be annotated I was a bit disappointed.

  20. Avatar
    John Sonmez about 23 hours later:

    Some very good points. There seems to be a widespread overuse of DI frameworks to solve every problem. I am beginning to feel that we need a language solution to eliminate the problem at the source instead of trying to cure it with frameworks. Anytime I see frameworks abounding, I think language evolution.

  21. Avatar
    Dave LeBlanc 1 day later:

    I think I’m going to have to side with J.B. on this one – I don’t believe that this advice is really leading to a big payoff for most developers.

    In particular, there’s the ‘propagation of dependencies’ antipattern (http://www.picocontainer.org/propagating-dependency-antipattern.html), which you don’t seem to show any solutions to. And I’m concerned that the non-DI container steps you would probably take to avoid that antipattern would actually be more complicated than just using a lightweight DI library. (Passing around a context object that contains common dependencies being a common approach).

    Dependence on a specific DI framework – agreed, that’s not a good thing. Should we preemptively spend developer time just in case we may need to switch out our DI implementation? I don’t think so – not if I was paying for the project. I don’t abstract away from the fact that I’m using a particular GUI toolkit (or JS toolkit, etc) these days – sure I might change it, but odds are I wont, and the cost of that abstraction is very real. Truth be told, all the projects I’ve been on have just stuck with what they were using for DI stuff, and the cost to change an @Inject annotation to a synonymous approach is near-zero.

    Though I think I agree with the core of your sentiments – if our POJO’s were free of DI specifics, and just loosely coupled via interface dependencies (which are resolved clearly at the top level), then that’s a good place to be. And for small projects, manual DI is almost certainly preferable.

    Dean’s suggestion of the Scala way to do it is interesting – use language level features that don’t really bind you in any way, and still allow alternate implementations to be used in a test environment. But truth be told, I’ve found that guice still reads better for me (right now) in this role.

  22. Avatar
    cn 1 day later:

    Just a fyi.. The @Inject annotation along with a bunch of other DI related annotations have been standardized in javaee 6 (JSR-299 and JSR-330). So once we upgrade to javaee 6 (or use a DI container like Spring 3.0 which implements JSR-330) we will not have framework specific annotations (and imports) scattered all over the place.

  23. Avatar
    FShehadeh 1 day later:

    Thanks for the nice article; it raises some very interesting questions. I think that the key point is that we are not interested in the DI frameworks per se, but we should be interested in the basic notion of DI: objects shouldn’t know about their surroundings, and an external entity should be responsible for instantiating the objects and wiring them together. We can do this manually, but as we do this over, a pattern will eventually emerge and we will end up with some form of a framework to help us do DI. If we reach this point, then I think that is better to reuse a standard DI framework rather than rolling one of our own. At the very least, the third-party framework (be it Guice or Spring) will be familiar to more developers, and it will have more experienced developers supporting it.

    One key area where flexible DI frameworks shine is where we need to have different object-wirings for different situations. For example, when running unit tests, or on a mobile device, or so on. In each of these cases, we might want different implementations to be plugged in to address the specific problem at hand, and a DI framework would provide more flexibility in doing this.

  24. Avatar
    Howard Lewis Ship 1 day later:

    Yes, this tiny example is worthless. I use DI extensively in Tapestry and it solves a lot of problems that Uncle Bob is glossing over.

    First of all, late binding is very important when building a framework that must allow for extensions by third party libraries or by specific applications.

    A DI container makes thread-safe just-in-time instantiation possible in a way that is not feasable for an ad-hoc collection of objects. Further, Tapestry IoC adds other features, such as service decoration & advice wherein different concerns of a service can be layered together.

    My experience is that on any large system, DI is quite necessary (in Java, at least … higher level languages like Clojure have less need, because the language itself provides the benefits of a DI container).

  25. Avatar
    Eirik Maus 1 day later:

    I think we all (more or less) agree that most systems need some kind of dependency injection mechanism, or else they become a total mess.

    I, however, still stick to the “xml-god-help-us”-solution, as this is the only way to ensure that the implementation classes are independent of the dependency injection framework (well, most are, at least).

    I haven’t much experience with the annotation-based systems, but as far as I can tell they seem to make it very difficult to exchange dependency implementation to use for a specific test case. If find it very similar to early j2ee dependency resource lookups, which is nearly the opposite of dependency injection. The syntax is a whole lot better, though.

    For systems where responsiveness or consistency in various scenarios is extremely important (and probably a lot of other cases too), you get quite some amount of tests simulating various interleavings of concurrent actions, different kinds of integration-point breakdowns etc where a specific ‘bean’ or two must be replaced in each test case in order to simulate the breakdown. Re-binding implementation classes can easily wreck the other tests in the test suite or make the execution order significant. Seems to me that the simple solution is to not have anything magically @inject’ed.

    Also: dependency injection framework fashion is extremely short lived. You might want to switch.

  26. Avatar
    Roy van Rijn 1 day later:

    I took some time to describe how I usually teach Spring/Guice.

    Like I commented before, its based on the fact that the DI-pattern is much much more important then the actual framework of choice.

    You have to understand why you are using a certain pattern/framework, what problem are you in fact trying to tackle or avoid? That is the single most important thing.

    You can read my tutorial/write-up here: http://www.redcode.nl/blog/2010/01/dependency-injection-dissection

  27. Avatar
    Colin Decker 1 day later:

    Uncle Bob, I noticed in a comment elsewhere that you thought it was funny that people were saying your example was too simple when it was straight from the Guice tutorial. There are a couple of issues with that. The Guice tutorial, as a basic introduction to how Guice is used, is naturally going to be simple. The problem with you using that example to say “look, you don’t need a DI framework!” is that Guice is considerably more powerful than the example suggests and scales very well with increasing size and needs of a system (scopes, etc.) where DI by hand does not (it requires explicit wiring of every object your system needs and provides nothing in terms of scoping, delayed instantiation, etc). In other words: in a tiny example, DI by hand looks like a perfectly acceptable solution while Guice looks unnecessary (though even in such a tiny example it doesn’t require more code than doing it by hand)... there’s a strong bias toward the frameworkless code. In a real system that will likely have considerably more dependencies and more complex dependency graphs, a framework will shine by making your code simpler and more focused and overall reducing the amount of code you have to write.

    I also get the feeling that part of your motivation for this post is seeing code where a DI framework has been misused, such as injecting the Injector (where it isn’t truely needed) or, god forbid, using a static reference to it all over the place as a Service Locator. In that case I would suggest that the solution is not static references to factories or DI by hand but proper use of the framework. I do agree with you that using some kind of DI is the most important thing and I think that someone who doesn’t yet have a grasp on DI should understand DI by hand before using a framework. However, I’d prefer to see you encourage understanding and proper use of DI frameworks rather than suggesting they are largely unnecessary, as they DO provide significant benefits.

  28. Avatar
    Jeffrey Palermo 1 day later:

    When I read this post, I made it mandatory reading for all of my employees. Having use an IoC container for 5 years now, I have recognized the pendulum swing to abuse it by lying to ourselves by believing that is is not a global and that it in itself is not a dependency.

    Late last year, I made an architectural move across the company to officially decouple ourselves from our IoC container (StructureMap). there were too many code files throughout the application calling it’s API directly.

    We have now (in some projects) isolated it to a single startup project. These projects configure the specific factories we need as well as wire in extensibility points.

    I now consider it just as heinous a dependency as NHibernate or the UI toolkit in play. Our core project (the one with the most code) should not have anything to do with concrete dependencies.

    Thanks for the good post.

  29. Avatar
    Kees Overboom 1 day later:

    BillingModule and BillingServiceFactory both extend AbstractModule and do the same binding. Is this necessary to make things work? To me this seems a violation of SRP.

  30. Avatar
    Morten 2 days later:

    Ok, so you have the “we need an abstraction layer, just in case we want to replace X” argument. Have anyone ever heard this actually being followed up a year later by; “good thing we created that abstraction layer, now we can change X for Y”??

  31. Avatar
    Gal Ratner 2 days later:

    I think the key to this post was “I think these frameworks are great tools. But I also think you should carefully restrict how and where you use them.”

    I personally find they help me think clearly on how to design my modules. I have my own factory based framework, and yes, I prefer XML configuration, simply because of the added behavioral attributes and the fact that they save me from any specific code tags such as @Inject.

    I think this post is probably aimed more at Google’s Guice framework and less at DI in general.

  32. Avatar
    Jeffrey Palermo 2 days later:

    Here is an extension of this post with my opinion added.

  33. Avatar
    SeeR 3 days later:

    How about use of generics as a DI. No framework required.

    http://seermindflow.blogspot.com/2009/07/c-generics-free-but-ugly-dependency.html

  34. Avatar
    Eirik Maus 3 days later:

    @SeeR: The problem is that you are still doing dependency lookup instead of dependency injection. Using XML for configuration setup is not elegant, but at least it keeps configuring the services separate from the application logic. And IDEs provide the same level of coding support as they do for java these days, so it is in fact not more error prone anymore.

    The key to easily testable classes is to never mix configuration/setup with use. That is what this blog article is all about, as far as I can tell. If you need references to the DI framework inside the code, you are not keeping these apart. The result is easily a messy web of dependencies where it is not easy (/possible) to change any relationships for simple tests or for future program modifications.

    If you do dependency resolution in java code, you need to keep a strong focus on you coding style to prevent configuration code from sneaking into the init-validation or business logic code.

    The reason I still stick to XML is that it is not a programming language, making such mistakes impossible. That way you can always create code such as in this blog article, knowing that no service will ever try to “request” any “service” from the “environment” while it is running. The dependencies are injected before you run any program logic.

    Okay, sometimes framework- or infrastructure code do need to request other stuff at runtime, but since it requires additional effort to do this, it will be the exception, not the norm.

  35. Avatar
    Gavin Bong 3 days later:

    Why are people so afraid of annotations ? i.e. @Inject

    Although in Guice’s case, I would prefer that Guice specific annotations be shipped as a separate jar dependency (from framework code).

  36. Avatar
    Kees Overboom 3 days later:

    Off course I mean DRY instead of SRP. Sorry about that.

  37. Avatar
    Paulo Silveira 3 days later:

    Your solution seems not more decoupled than using Guice from outside the factory: if you need to change the DI framework (which is much more improbable than the need to change a component implementation) you will need to change every single factory.

    Having an @Inject annotation is not coupling! If you remove the framework, you dont need to remove the annotation.

    Also, for your simple example, wiring by hand is a perfect choice. Now, if you have lots of objects with different lifecycles and instantiation policies, you will have a lot of code just to tackle this. I think this is waht you mean with “externalized dependency injection of the kind that Guice provides is appropriate for those classes that you know will be extension points for your system.”, but I would say not only extension points, but also expesive objects that require some lifecycle attention (Hibernate Sessions, Http Sessions, Files, Threads, Connections and so on)

  38. Avatar
    Eliud 3 days later:

    Why not enable feed (RSS) on you blog. It would be nice.

    Greetings!

  39. Avatar
    freddy rios 4 days later:

    I generally agree with your posts, but not on this one.

    MM already mentioned 2 of the assumptions/generalizations taken on this post:

    —-—-—-—-—-

    - “I don’t want a bunch of secret modules with bind calls scattered all around my code.”

    So don’t scatter them. Put them all one place.

    - “I don’t want lots of concrete Guice dependencies scattered through my code.”

    I agree with this. I first learned about DI containers in the .NET world and when I saw that Guice requires constructors to be annotated I was a bit disappointed.

    —-—-—-

    In my case I’ve been using StructureMap in .net, and I don’t need any attributes/annotations on the classes. Pretty much all the dependencies are configured in a single place, so there is no issue involved with that.

    Only a single time I had a situation where I needed to get an instance from elsewhere in the code. Although I did made a factory to make more explicit the code into the DI container, I don’t think going without is an issue to change containers – take out the reference to the DI container, compile & u get the 0-3 lines of code that referenced it (besides the one in the main registration code of course).

  40. Avatar
    Fred 5 days later:

    I think this post is a little misleading and leaves out the most importend things about IoC. Reading Ayende’s answer to it should make this clear:

    http://ayende.com/Blog/archive/2010/01/22/rejecting-dependency-injection-inversion.aspx

  41. Avatar
    MikeHoss 5 days later:

    I posted my response here but the short answer is: it’s about knowing what you are getting into before you start, and the costs you may incur for your decisions when you start.

  42. Avatar
    shane kercheval 5 days later:

    I have two major concerns with this post. First. To say that “the goal of these frameworks is to help you create instances without having to resort to new or Factories”, in my opinion, is not at all what dependency injection is about at all. Dependency injection is about, as its name suggests, removing dependencies from your code, decoupling your code, making it more maintainable, and TESTABLE, among other things. The second concern i had was your examples didn’t show why someone would ever use DI. As you stated “My goal is to create an instance of BillingService.” While i agree that you shouldn’t use something just because its cool or everyone is talking about it, or without reason, I just really feel like your example missed the point.

    And i wasn’t sure why you were suggesting to use instances or factories?

    BillingService.factory = new BillingServiceFactory(injector);

    // Deep in the bowels of my code.
    BillingService billingService = BillingService.factory.make();

    ??

    The goal is NOT to stop or reduce using new (although it is a side effect of the pattern but not the purpose), and you dont have to use singletons or factories, which i extremely dislike that solution because you are changing the way you design/implement your classes because you use a IOC container, which i think is bad. Not only that but are you really going to make a factory for each class that you want to use DI with? no. The point is to reduce dependencies between concrete classes and program to an interface. So if you dont want Guice all over your code, which i wouldn’t want either because that creates a dependency which is the opposite of what we are trying to do, so what i would do is create a wrapper for Guice that way the application would not depend on that framework and it can be swapped out with any other framework. Now you dont have factories, instances everywhere and you are not tied to a DI framework.

  43. Avatar
    Svein Arne Ackenhausen 7 days later:

    Brilliant post! It created enough of a stir for people to post replies on their blogs leading to valuable insight into various frameworks. Now my DI framework usage is clean, simple and does wonders. Thanks, it really made my day!

  44. Avatar
    Mark Seemann 8 days later:

    After having re-read this post carefully, I think this particular piece of guidance is redundant in .NET.

  45. Avatar
    Eelco Hillenius 8 days later:

    Not my experience at all. I’ve gone full circle in first not buying into the DI hype and doing everything manually much like you describe, to using Guice as an important part of our architecture. For a long time I thought DI was an example of YAGNI, and I still feel this way when looking at e.g. Spring’s XML configuration, but since adopting Guice, our code got a lot cleaner and easier to configure.

    Manually constructing object graphs like you suggest here works fine for small-ish projects but easily gets out of hand in larger ones, particularly if such projects are broken up in multiple projects/ modules/ libraries. Modules provide an excellent mechanism to hide complexities of how such libraries are composed. You could achieve the same by providing builders and such, but then you’d be handwriting what a DI framework already provides. Also, @ImplementedBy and lazy binding provide an excellent way of reducing dumb setup code; in my experience, an composition of a module system uses defaults maybe 70 or 80 % of the time, so your bootstrapping code only has to configure composition for a relatively small number of cases.

    > There will always be globals to deal with. You can’t write systems without them

    I don’t agree with that. In fact, I am working on a system right now that has no globals to speak of. It requires discipline because it is often easier to rely on globals, but over the years I’ve learned – as many in our industry – that relying on global behavior almost always backfires, and like it is worth the extra effort to think your abstractions through, it is worth the effort of trying to keep the globals down.

  46. Avatar
    Craig McClanahan 9 days later:

    > Ok, so you have the “we need an abstraction layer, just in case we want to replace X” argument. Have anyone ever heard this actually being followed up a year later by; “good thing we created that abstraction layer, now we can change X for Y”??

    At my new digs (Jive Software), this exact capabity enables us to satisfy unique customer requirements on essentially every install. All the DAOs, managers, etc. are DI injected (currently based on Spring 2.5, would personally prefer @Inject style, we’ll see how long it takes to encourage the other developers in this direction :-), with an ability to install a “plugin” that overrides the default injected resources for any or all of the standard implementations. This is critically important in at least a couple of important use cases:

    • Customer wants to add functionality to an “off the shelf” capability.
    • Professional Services needs to tune the standard functionality of a particular capability, to deal with the fact that a particular customer has billions of records, instead of thousands of records, of this particular type.

    In a COTS world, anyone who thinks they know the only abstraction points where a customer might want to change things is pretty naive.

  47. Avatar
    Mike 9 days later:

    I thought you were being crazy until I read through half-way, and then I realised I had the same problem using IoC containers, they were all-over the place.

    Good lesson, thanks!

  48. Avatar
    Bob Lee 9 days later:

    Uncle Bob,

    You should take a closer look at Guice and DI in general.

    1) In a typical Guice application, you only use Injector in one place—at your applications entry point. Using Injector elsewhere is equivalent to using reflection. Injector is like ClassLoader, another class I hope you don’t use everywhere.

    2) To answer your question, no, the injector is not global, nor is the binding to BillingService.class. See private modules. You can easily bind BillingService to different implementations in different parts of your app.

    3) You suggested that “TransactionLog tl = new DatabaseTransactionLog()” is preferable to “bind(TransactionLog.class).to(DatabaseTransactionLog.class)”. What happens when you need to inject TransactionLog into a 2nd constructor? You have to type “TransactionLog tl = new DatabaseTransactionLog()” again. With Guice, you do nothing. What happens when you use TransactionLog in 100 places? You type “TransactionLog tl = new DatabaseTransactionLog()” 100 times in 100 different factories. With Guice, you only write one bind statement. Your approach scales O(N). Guice scales O(1). Perhaps you didn’t realize it because N=1 in your example.

    Further, if TransactionLog is a concrete injectable class to begin with, you don’t even need a bind() statement. If you decide to replace it with an interface later, you can do so without touching the 100 injection points. Can you do that with your approach?

    4) If you don’t use javax.inject.Inject in your code simply because you don’t “want framework code smeared all through [your] application,” you’re making a pretty painful tradeoff.

    5) Static fields are notoriously bad for unit testing. We walk you through examples of why in just about all of our Guice videos.

    Bob

  49. Avatar
    Donnie 14 days later:

    Hah,that was really funny. I even ordered an essay paper on it.These online essay writers made an excellent essay for me.

  50. Avatar
    Derek Smyth 18 days later:

    I’ve never really used a dependency injection framework in a project for exactly the reasons mentioned. I’ve experimented with a few frameworks and most of them (if not all of them), by their design or by my mistake, added some level of noise and misdirection to the code.

    Just didn’t seem worth it, the additional noise.

    Really glad this was posted as I wondered whether I was really doing DI even though it felt like it.

    Ok some people will argue I am still not doing DI properly, and maybe a situation will arise when I’ll reach for a framework, sure ok I’m easy… but all my code is testable and it’s obvious where and why concrete classes are created; don’t need a framework.

  51. Avatar
    Omar Gomez 25 days later:

    Your point seems to be that you should not use dependency inversion frameworks to make simplistic samples like the one above. A good frame work support many other things like aspects, and transaction handling (to name just two). I want to see how you refactor your code to support that.

    —Omar

  52. Avatar
    psn card about 1 month later:

    Hah,that was really funny. I even ordered an essay paper on it.These online essay writers made an excellent essay for me.

  53. Avatar
    UGG Classic Metallicaz` 2 months later:

    welcome to http://www.uggboots4buy.com/ l,will have a unexpection.

  54. Avatar
    moncler clearance 2 months later:

    Very quietly I take my leave.To seek a dream in http://www.edhardy-buy.com/ starlight.

  55. Avatar
    Kooba Handbags 2 months later:

    Living without an aim is like sailing without a compass. with a new http://www.handbags4buy.com/ idea is a crank until the idea succeeds.

  56. Avatar
    highkoo ugg boots 2 months later:

    all products are high quality but low price,welcome to http://www.uggjordanghd.com/.

    >
  57. Avatar
    parça TL kontör 3 months later:

    Very nice art, thank you for this site!

  58. Avatar
    parça TL kontör 3 months later:

    Very nice art, thank you for this site!

  59. Avatar
    funny motivational posters 3 months later:

    Thanks for the code. I’ve never tried this stuff before and wonder if it can even be done. WIll give it a shot tonight, a long read but surely worth it. Thanks.

  60. Avatar
    Blu-ray ripper mac 3 months later:

    OK, just have a free try!!

  61. Avatar
    Cleaning Service Blog 3 months later:

    It’s sometimes easier to see a problem with a framework clearly when you step back and create an example like this. When you’re in the thick of it your brain can trick you into thinking that there’s only one way at the problem.

  62. Avatar
    Poptropica Cheats 3 months later:

    I like that the high-level modules do not depend on low-level modules. Both should depend on abstractions. This is one of the principles of dependency injection framework I am raving.

  63. Avatar
    Health Insurance 3 months later:

    Mosst high level modules are extremely independent of themselves. Injection framework insures that this process is seamlessly taken care of.

  64. Avatar
    Health Insurance 3 months later:

    Mosst high level modules are extremely independent of themselves. Injection framework insures that this process is seamlessly taken care of.

  65. Avatar
    Car Rims 3 months later:

    Your point seems to be that you should not use dependency inversion frameworks to make simplistic samples like the one above. A good frame work support many other things like aspects, and transaction handling (to name just two). I want to see how you refactor your code to support that.

  66. Avatar
    Indianapolis movers 3 months later:

    When you’re in the thick of it your brain can trick you into thinking that there’s only one way at the problem.

  67. Avatar
    jailbreak iphone 3 months later:

    When you’re in the thick of it your brain can trick you into thinking that there’s only one way at the problem.

  68. Avatar
    640-802 3 months later:

    High quality Cisco, HP, IBM, Oracle and other Certification exmas training materials are provided here atPass4sure Pass4sure helps you on your way to your certifications,Click 640-802 to get more information!

  69. Avatar
    640-553 3 months later:

    High quality Cisco, HP, IBM, Oracle and other Certification exmas training materials are provided here at Pass4sure Pass4sure helps you on your way to your certifications,Click 640-553 to get more information!

  70. Avatar
    openhair.de 3 months later:

    Manually constructing object graphs like you suggest here works fine for small-ish projects but easily gets out of hand in larger ones, particularly if such projects are broken up in multiple projects/ modules/ libraries. Modules provide an excellent mechanism to hide complexities of how such libraries are composed. You could achieve the same by providing builders and such, but then you’d be handwriting what a DI framework already provides. Also, @ImplementedBy and lazy binding provide an excellent way of reducing dumb setup code; in my experience, an composition of a module system uses defaults maybe 70 or 80 % of the time, so your bootstrapping code only has to configure composition for a relatively small number of cases.

  71. Avatar
    Gift Ideas for Men 3 months later:

    Without the concept of dependency injection, a consumer who needs a particular service in order to accomplish a certain task would be responsible for handling the life-cycle (instantiating, opening and closing streams, disposing, etc.) of that service.

  72. Avatar
    apotik online 4 months later:

    Very nice work you have there, thank you for sharing with me. Been looking for such code for a while now.

  73. Avatar
    sauna 4 months later:

    I actually prefer using xml, mostly because I understand it.

  74. Avatar
    <a href="http://acircutcity.com">Jack Hills</a> 4 months later:

    i think Dependency Injection has gained lots of popularity in last two to three years. It is mainly getting popularity because of its code simplification effects. lots have already been said DI benefits and i think there is more to say. So thanks for this article and keep contributing on benefits of DI.

  75. Avatar
    Jack Hills 4 months later:

    i think Dependency Injection has gained lots of popularity in last two to three years. It is mainly getting popularity because of its code simplification effects. lots have already been said DI benefits and i think there is more to say. So thanks for this article and keep contributing on benefits of DI.

    (sorry for double comment, i request to remove the above comment)

  76. I always prefer PHP with Ajax for fast results.

  77. Avatar
    liposuction for men 4 months later:

    Any idea how often Google’s Guice framework updates?

  78. Avatar
    online payroll 4 months later:

    I think multiple factory can make your things more messy.

    You should look for some other reliable and proper options.

  79. I also find XML easier to understand. However, I understand the benefits of Java Scripting, CSS and the like.

    Thank you for this. It was a very interesting discussion to read.

  80. Avatar
    Saskatoon SK Real Estate 4 months later:

    Wow. Amazing insight! Thanks for this! Saskatoon SK Real Estate

  81. Avatar
    Burnaby Homes 4 months later:

    Great work! This is really interesting stuff. Looking forward to reading more.

  82. Avatar
    chase personal loans 4 months later:

    Definitely agree with what you stated. Your explanation is certainly the easiest to understand about dependency injection.

  83. Awesome code!

  84. Avatar
    crazy taxi 4 months later:

    Very good article, thanks for the tips. It is useful even for beginners

  85. Thanks for this awesome code!

  86. Avatar
    Patrick Kalkman 4 months later:

    Thanks for your view on dependency injection, we are in the process of selecting and using our first DI framework. Your post helps to determine where to use automatic DI.

  87. Avatar
    kerala used car 4 months later:

    I am very thankful to you. The code made my project working. I got total output

  88. Avatar
    Aline 4 months later:

    OK, just have a free try!!

  89. Avatar
    dinamic soft 4 months later:

    it is good to know how we can prevent… thank you for the tips

  90. Avatar
    vhskid 4 months later:

    Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your post

  91. Avatar
    igec 4 months later:

    i found this in google search, very intersting article, thanks for sharing

  92. Avatar
    kelowna Hotels 4 months later:

    great post almost understood it. my programmers handle all my xml stuff….now i see why.

  93. Avatar
    louis vuitton 4 months later:

    go to wow very good

  94. Avatar
    bird feeders 5 months later:

    Thanks for the code. I’ve never tried these things before and wonder if it can be done. Will it give a night shot, a long reading, but certainly worth it. Thank you.

  95. Avatar
    Shoulder Holster 5 months later:

    Using XML to inject dependencies is a total nightmare. What reasonable person would do that? This outline is a much more effective approach.

  96. Avatar
    mahjong 5 months later:

    Thanks guys for the publication of this material. I’ll use your code.

  97. Avatar
    travel vacation tips 5 months later:

    Nice post, I’ve really enjoyed reading your articles. You obviously know what you are talking about! And Your site is so easy to navigate too, great blog.

  98. Avatar
    Unlocked Cell Phones 5 months later:

    Thanks for theNice post, I’ve really enjoyed reading your articles. You obviously know what you are talking about! And Your site is so easy to navigate too, great blog. code. I’ve never tried these things before and wonder if iNice post, I’ve really enjoyed reading your articles. You obviously know what you are talking about! And Your site is so easy to navigate too, great blog.t can be done. Will it give a night shot, a long reading, but cerNice post, I’ve really enjoyed reading your articles. You obviously know what you are talking about! And Your site is so easy to navigate too, great blog.tainly worth it. Thank you.

  99. Avatar
    aprella 5 months later:

    hmmmmm,. I don’t know this post ;) but, I think it’s great,.. and maybe I can learn about it latter,. great blog,. keep share!,. ty

  100. Avatar
    granite colors 5 months later:

    Hah,that was really funny. I even ordered an essay paper on it.These online essay writers made an excellent essay for me. Granite Colors | Granite Countertops | Granite VA | Granite MD | Granite Remnants Granite Maryland | Granite Virginia

  101. Avatar
    Sarkari naukri 5 months later:

    Hi, I would like to thank everyone the hard work you spent as Google’s Guice framework Thankyou

  102. Avatar
    haunted places 5 months later:

    Thanks for the tips on framework and putting in terms I can understand:)

  103. Avatar
    Beauty - Healing Center 5 months later:

    Thanks for the code. I’ve never tried these things before and wonder if it can be done.

  104. Avatar
    industry news 5 months later:

    I tried it and it works… thanks… now my application is safer

  105. Avatar
    pub quizzes 5 months later:

    Great – tried & tested, many thanks!

  106. Avatar
    usa casinos online 5 months later:

    Thanks, it was usefull code for me!

  107. Avatar
    ecuadorianshoeproject 5 months later:

    For me too!

  108. Avatar
    superman 5 months later:

    We only use constructor injection and use StructureMap to auto wire it up. All we need is:

    Scan(x => { x.Assembly(“MyAssembly1”); x.Assembly(“MyAssembly2”); x.WithDefaultConventions(); });

    DefaultConventions ties up the interface with its concrete class, eg ICustomerService to CustomerService. Then we only need to be specific when the lifecycle of the instance is different.

  109. Avatar
    Martin 5 months later:

    Regarding the registration, not sure about all the other container but both Windsor and StructureMap will allow you to register your entire application with a few lines of codes with a fluent interface :)

  110. Avatar
    Skinny Switch Secret 5 months later:

    Yes, both Windsor and StructureMap make it easy to register the whole application using very little code.

  111. Avatar
    Hoover S2220 5 months later:

    I’m still not sure what the appeal is for javascripting, CSS, etc.. I prefer sticking to XML personally. At any rate, I appreciate the read.

    Cheers.

  112. Avatar
    Shopping 5 months later:

    I really like this new version. Wanna support for this for further development. I had some good command on the Arabic language. So I can satisfy well with this blog.

  113. Avatar
    Smart Business Solutions 5 months later:

    Thanks for theNice post, I’ve really enjoyed reading your articles. You obviously know what you are talking about! And Your site is so easy to navigate too, great blog. Trendy Fashion Jewelery, erwinwellen, Home Improvement Tips

  114. I can confirm that this works. thank you for the wonderful tip.

  115. Avatar
    Rancho Santa Fe Real Estate 5 months later:

    I am glad that the windsor registration was so smooth. It was just a few lines of code and it implemented without a hitch.

  116. Avatar
    jewellery 5 months later:

    It was just a few lines of code and it implemented without a hitch.

  117. Avatar
    jewellery 5 months later:

    virtual expos online from the comfort of your own home.

  118. Avatar
    Signs Austin 5 months later:

    for a safer application it is better to prevent this kind of injection. I tried that code and it works. you can use it!

  119. Avatar
    dan 5 months later:

    I too can confirm that this works

  120. Avatar
    Ecommerce website 5 months later:

    I tried that code and it is safe… you can not hack my database anymore. Thanks!

  121. Avatar
    baseball jerseys 5 months later:

    virtual expos online from the comfort of your own home.

  122. Avatar
    posterrahmen 5 months later:

    Using XML to inject dependencies is a total nightmare. What reasonable person would do that? This outline is a much more effective approach.

  123. Avatar
    fnews 5 months later:

    Nice. I used all of these protection methods in my website.

  124. Avatar
    simulation assurance auto 5 months later:

    Thanks for the explained process. I am very familiar with the entire set-up, and have done work almost identical to the ones shown.

  125. Avatar
    MM 5 months later:

    Bob Lee wrote:

    What happens when you need to inject TransactionLog into a 2nd constructor? You have to type “TransactionLog tl = new DatabaseTransactionLog()” again. With Guice, you do nothing. What happens when you use TransactionLog in 100 places?

    Guice let’s me to postpone the decisions of what concrete instances to use, but I hope that we don’t forget that delaying commitment on design issues is beneficial too: Speculative design has it’s costs, and I’d prefer to use factories only after I have noticed it to be necessary, and Guice or any other DI FW only after I have decided that I need one.

  126. Avatar
    wholesale Jordan shoes 6 months later:

    Hello All, I just wanted to start by saying that the contribution here is simply amazing.

  127. Hiya. I’m definitely interested on this subject. Might you be publishing anything at all else about this?

  128. Avatar
    bar furniture 6 months later:

    Inyections in weak scripts can simply break the codes… specially when dealing with open source scripts

  129. Avatar
    how to dunk 6 months later:

    This article has given me some interesting points on scripting.

  130. Avatar
    PSP ISO 6 months later:

    Now that is one hell of a article. I could only dream of doing something like that !

  131. Avatar
    stock market 6 months later:

    This article gives the light in which we can observe the reality. This is very nice one and gives in depth information. Thanks for this nice article. Good post…..Valuable information for all.

  132. Avatar
    Vinyl Lettering 6 months later:

    Great article, a bit over my head but definitely some new concepts learned.

  133. Avatar
    pewter 6 months later:

    Several frameworks that will help you inject dependencies into your system can be found all over the internet. If you need particular software or webservice, here is where to find your website development experts.

  134. Avatar
    mahjong 6 months later:

    Thanks for the article. Good examples of code. I would use.

  135. Avatar
    Archaeologists 6 months later:

    Without the concept of dependency injection, a consumer who needs a particular service in order to accomplish a certain task would be responsible for handling the life-cycle (instantiating, opening and closing streams, disposing, etc.) of that service.

  136. Avatar
    Androgynous fashion 6 months later:

    Romance is out of summer, the perfect period. Outing Romantic, melting snow spins dress is today season vogue girls wear build up the important sheet is tasted, using qualitative produce elegant light spins the romantic sense, plus the broken this year popular element , presents different female glamour. The frivolous fabrics spins or cultivate one’s morality is best, clear and elegant texture to help you hide fat shape, block butterfly arm.

  137. Avatar
    Flared jacket 6 months later:

    Flower skirt seems to be in summer, forever ChanYi as thin as the flower skirt, can not only a cool summer, and all sorts of design and color, let you do in summer “ever-changing princess”, plus all sorts of collocation, individual character is dye-in-the-wood, the flower skirt collocation of snow, cowboy ma3 jia3, formed the integral style of contrast, let you both cooling and handsome!Tie-in skill: flower skirt handsome ma3 jia3

  138. Avatar
    wacom accessories 6 months later:

    this dependency injection resource is unparalleled on the entire WWW

  139. Avatar
    shahzad 6 months later:

    However If you’re interested in finding Funny SMS Collection or latest Birthday SMS or great collection of Friendship SMS then go to CuteSMS.net to find them out.

  140. Avatar
    Travis 6 months later:

    Now that is a good article. I could only dream of doing something similar

  141. Avatar
    Lindsay 6 months later:

    What is this? Jk This is soo complex

  142. Avatar
    retirement communities 6 months later:

    how can I use it for my site? how can I have a safe database?

  143. Avatar
    Ghandi 6 months later:

    Its extremely important to know where all the instances are created, if you dont, you loose track and control of the structure of the object that is being coded. Naturally, I believe we tend to not author protocols and hence loose track of the core issue, which is in my opinion, control. thanks.

  144. Avatar
    business messaging service 6 months later:

    I have never thought that surfing online can be so much beneficial and having found your blog, I feel really happy and grateful for providing me with such priceless information.

  145. Avatar
    carmeron 6 months later:

    this dependency injection resource is unparalleled on the entire WWW

  146. Avatar
    jingjia 6 months later:

    iPhone Ringtone Custom turns your dream of making your own iPhone/iPhone 3G Ringtone with loved music into reality in the way of converting almost all mainstream video/audio format to M4R iPhone ringtone, such as avi, mpeg, mp4, mov, flv, mp3, aac, m4a, wma, etc. to M4R iPhone Ringtone, even rip DVD Disc to Ringtones for iPhone. Convert to iPhone Ringtone Change iPhone Ringtone Convert Music to iPhone Ringtone Convert MP3 iPhone Ringtone Convert M4A to M4R Convert MP4 to iPhone Ringtone

  147. Avatar
    John 6 months later:

    yes this does work. thanks!

  148. Avatar
    chanel jewelry 6 months later:

    This was a good read, kinda early in the morning though. Should do some work Laughing lol

  149. Avatar
    michetela 6 months later:

    Good post. I am also going to write a blog post about this…

  150. Avatar
    business messaging service 6 months later:

    This looks absolutely perfect. All these tinny details are made with lot of background knowledge. I like it a lot. Keep on taking action!

  151. Avatar
    dentist in acton 6 months later:

    Excellent information here. This blog post made me smile. Maybe if you put in a couple of pics it will make the whole thing more interesting.

  152. Avatar
    phlebotomy training 6 months later:

    I like how you managed to put all the Guice stuff inside a factory. I do expect, though, that in a real application, with multiple factories for different object, it would become a bit messy. But it’s concentrated mess.

    I have to ask – when do you consider moving from hand written test doubles to a framework? And where in a TDD process would you decide that?

    Gil Zilberfeld

    Typemock

  153. Avatar
    Repair Manuals 6 months later:

    This was a really quality post. In theory I’d like to write like this too,taking time and real effort to make a good article…

  154. Avatar
    vermageren 6 months later:

    Wishing you the best of luck for all your blogging efforts.I will revisit your website for additional information.

  155. Avatar
    Soap opera spoilers 6 months later:

    Manually constructing object graphs like you suggest here works fine for small-ish projects but easily gets out of hand in larger ones, particularly if such projects are broken up in multiple projects/ modules/ libraries. Modules provide an excellent mechanism to hide complexities of how such libraries are composed. You could achieve the same by providing builders and such, but then you’d be handwriting what a DI framework already provides. Also, @ImplementedBy and lazy binding provide an excellent way of reducing dumb setup code; in my experience, an composition of a module system uses defaults maybe 70 or 80 % of the time, so your bootstrapping code only has to configure composition for a relatively small number of cases.

  156. Avatar
    Scaffold boards 6 months later:

    One issue in this example is in your presumption of how DI frameworks are generally used. I think it’s important to draw a distinction between Dependency Injection and the Service Locator pattern here.

  157. Avatar
    Guaranteed listing on dmoz 6 months later:

    DMOZ Directory or ODP is a human managed directory that sends results or data to search engines. DMOZ directory data is now used by the majority of major search engines on the net.

  158. Avatar
    short uggs 6 months later:

    This was a really quality post. In theory I’d like to write like this too,taking time and real effort to make a good article…

  159. Avatar
    yalova emlak 6 months later:

    Thank you very much for this article.I like its.As to me it’s good job.

  160. Avatar
    euro lottery 6 months later:

    e-lottery has thousands of members worldwide, all of whom enjoy the advantages that membership brings. Since its inception and the start of trading operations, e-lottery has paid out millions of pounds in winnings to its syndicate members and millions of pounds in commission to its Business Affiliates.

  161. One issue in this example is in your presumption of how DI frameworks are generally used. I think it’s important to draw a distinction between Dependency Injection and the Service Locator pattern here.

  162. Avatar
    Funniest videos 7 months later:

    Crazyvids.org is a website designed for sharing with our visitors the craziest and funniest videos we can find on the internet.

  163. Avatar
    coach wallet 7 months later:

    thanks for your sharing, I appreciate this. keep up the good work

  164. Avatar
    Just another Java guy 7 months later:

    I used Guice in a real life project (about 140k lines of code). It did make life easier, but the guys who where supposed to continue developing, decided to build around it, because they didn’t understand how my “bunch of secret modules” worked. They said they like the architecture, but don’t understand how the wiring works. That sucked. Explaining didn’t help either.

    Regards

  165. Avatar
    grinder pump huntersville 7 months later:

    Great blog it’s not often that I comment but I felt you deserve it. I enjoyed reading it!

  166. Avatar
    Ittay 7 months later:

    Too many comments to read, but I wanted to mention that with Spring (I don’t know Guice) the benefits of letting Spring create instances for you is that you get support for other mechanisms: 1. bean factories: which let you conform non-beans into the java beans pattern 2. property placeholders (which otherwise means the bean needs to have a reference to the Properties object in order to configure itself) 3. bean post processors 4. XxxAware interfaces which allow to auto inject values to a bean

    5. In fact, for me the advantage of Spring is not because it is an DI container, but because it creates a lifecycle for my beans (services)

  167. Avatar
    Watches 7 months later:

    This blog is very nice.I will keep coming here again and again.Visit my link as follows: watches <\a>

  168. Avatar
    Paula 7 months later:

    Incredible share. Amazing article. Love this facts. Thanks for the great work.

    Paula from MDR-RF925RK MDR-IF240RK Sennheiser HD 202 Record Label Business Plan

  169. Avatar
    man mall 7 months later:

    Thank you very much for this article.I like its.As to me it’s good job. cheap replica rolex cheap replica omega manmall replica rolex

  170. Avatar
    router compare 7 months later:

    This article gives the light in which we can observe the reality. This is very nice one and gives in depth information. Thanks for this nice article. Good post…..Valuable information for all. Gaming Wireless Router Greets J.V

  171. Avatar
    Marine fuel tank 7 months later:

    t is mainly getting popularity because of its code simplification effects. lots have already been said DI benefits and i think there is more to say.

  172. Avatar
    Cuddy cabin boats 7 months later:

    Without the concept of dependency injection, a consumer who needs a particular service in order to accomplish a certain task

  173. Avatar
    Harry Potter 7 months later:

    Well done! Looking for more interesting post from your end. Thanks a lot!

  174. Avatar
    türkçe porno 7 months later:

    you sen admin thanks

  175. Avatar
    offirk@hotmail.com 7 months later:

    the best downloads warez release : http://www.httpdl.com

  176. Avatar
    matty 7 months later:

    excenlent writing, informative and well structure. a particular service in order to accomplish a certain task

    Drug 4 Health

  177. Avatar
    oxuelite pro 7 months later:

    I remember this show, which will benefit both will remember. Each month, so that rewatched the first cycle of a new one.

  178. Such a long list of comments..

  179. Avatar
    Michigan Medicare 7 months later:

    Well written article.. Good Job

  180. Avatar
    Digital Photography 7 months later:

    It was a great post and informative too.Thanks for sharing.

  181. Avatar
    Rocking chair pads 7 months later:

    It’s a good blog. It’s a really good blog. Oh I don’t mean his silly complaining about C++ or Templates or COM.

  182. Avatar
    Decorative wall shelves 7 months later:

    nd sure there are “architecture astronauts” that understand how and why to use specific technologies, but in my experience most people only think they know these things, creating maintenance nightmares.

  183. Avatar
    Free Cpanel Hosting 7 months later:

    I found that when I wanted more information the links provided me with what I was looking for.

    Great ideas and tips. I’ve always had trouble finding a free place to blatantly a dvertise my products and services so I made one.

  184. Avatar
    bridesmaid dress patterns 7 months later:

    Interesting. His point is that by overusing DI frameworks, we are creating an application that has a strong dependence on these, we have to invest.

  185. Avatar
    Prices Tech 7 months later:

    Uncle Bob, thanks for the wonderful post. I don’t always agree with what you have to say (and that’s a good thing) but this one I thin hit the nail succinctly and elegantly on the head.

  186. Avatar
    first up gazebo 7 months later:

    This is the best thing that i read. thank you guys for this great stuff!

  187. Avatar
    Roxy Bedding 7 months later:

    Uncle Bob, thanks for the wonderful post. I don’t always agree with what you have to say (and that’s a good thing) but this one I thin hit the nail succinctly and elegantly on the head.

  188. Avatar
    donate your car 7 months later:

    ah. this tutorial what i looking for.thanks for providing this. i need it for my college work

  189. Avatar
    accident claims 7 months later:

    Some great info here, but as you say surely it is easier creating concrete instances rather than all of this overblown stuff. Maybe it would be better working on much larger apps but a bit overcomplex for my needs. Much prefer the simpler way that you laid out.

  190. Avatar
    Online Baseball Equipment 7 months later:

    This tutorial has really helped, thank you so much.

  191. Avatar
    <a href=”http://www.clairemeaderecruitment.co.uk/”>Domestic Staff</a> 7 months later:

    This is very interesting and quite informative. Gotta be honest i dont get it 100% but im still learning… Also i dont really understand how this is controversial… But maybe its just over my head.

  192. Really very good post. I really appreciate for this post. keep posting up. I learned something new.

  193. Avatar
    Domestic Staff 7 months later:

    This is very interesting and quite informative. Gotta be honest i dont get it 100% but im still learning… Also i dont really understand how this is controversial… But maybe its just over my head.

  194. Avatar
    Bingo Deposit Bonus 7 months later:

    I expect that in a real application, with multiple factories for alternative object, it would probably become a little messy.

  195. Awesome. I just tried the code and it works wonderfully

  196. Avatar
    hilarious quotes 7 months later:

    Me too prefer Ajax + PHP

  197. Avatar
    Exporters directory 7 months later:

    Great post. I’m very impress with this post,Thanks for sharing this information.

  198. Avatar
    http://www.turbovps.com/ 7 months later:

    cheap VPSReally very good post. I really appreciate for this post. keep posting up. I learned something new.

  199. Avatar
    single woman 7 months later:

    Like one of the earlier posters said, I don’t always agree with what you say but this one is right on.

  200. Avatar
    Apricot Tree 7 months later:

    Thanks a lot for this post. It’s incredibly informative. If you do not mind, I have a question; How do you deal with Spam in blog comments? I genuinely hate it, It wastes my time and I hate dealing with it each day. Do you have any suggestions for what I can do to reduce the quantity of comment spam I get on my blog? Thanks for your suggestions.

  201. Avatar
    cheap ghd 7 months later:

    A boaster and a liar are cousins-german.

  202. Avatar
    Carly 7 months later:

    This looks good and true.

  203. Avatar
    Jeff 7 months later:

    I also prefer php+Ajax

  204. Avatar
    Indotopnews 7 months later:

    I learned a long but not too .. thanks Adda results may be useful for my article

  205. Avatar
    jeux concours 7 months later:

    i aslo prefer php it’s much good for this !!!!

  206. Avatar
    voyager pas cher 7 months later:

    very good blog and interesting blog thanks a lot

  207. Avatar
    referencement grenoble 7 months later:

    This is the best thing that i read. thank you guys for this great stuff!

  208. Avatar
    travel agents 7 months later:

    Th4t be an epic da shizzi4 post, th4nkie 4it & in da futures we’ll be seeing more of it

  209. Avatar
    cruises 7 months later:

    We7ll I8be dat9 ogr6e speekie da speekie, gratz & than4x

  210. Avatar
    flight center 7 months later:

    heb7e sh8at be th34nkie 4it on da posting left & righ8ty

  211. Avatar
    charlotte 7 months later:

    Hope you go on like this… good luck!

  212. Avatar
    katrina kaif wallpapers 7 months later:

    Like one of the earlier posters said, I don’t always agree with what you say but this one is right on.

  213. Avatar
    Flat brim hats 7 months later:

    Is it so good?

  214. Avatar
    Inflatable 7 months later:

    Good blog and I liked it.Thanks for posting.

  215. Avatar
    4ndr1z 7 months later:

    Thanks For Sharing :)

  216. Avatar
    A line skirt 7 months later:

    In this article, she look so amazing. She always prepare a performance maximally. That great!

  217. Avatar
    chris 7 months later:

    yeah. I get it now of this Dependency Injection Inversion.

  218. Avatar
    costa 7 months later:

    Thanks a lot for this post.It is very informative.But one thing i clarify from you….... How do you deal with Spam in blog comments? I genuinely hate it, It wastes my time and I hate dealing with it each day. Please suggest me what to do. http://www.chichilnisky.com/

  219. Avatar
    daisy 7 months later:

    I like your blog.You provided such a good blog.It contains all the relevant information. http://www.fabricarehouse.com/

  220. Avatar
    UK Loans Arranger 7 months later:

    Very informative post thanks for the effort you have put into this.

  221. Avatar
    News Daily 7 months later:

    Very informative post, thanks for sharing

  222. Avatar
    alice 7 months later:

    Nice blog and i like the new content. http://surfaceid.com

  223. Avatar
    naperville chiropractor 7 months later:

    Now that is one hell of a article. I could only dream of doing something like that !

  224. Avatar
    mike 7 months later:

    Very nice art, thanks !!! —-—-—-—-—-— laptopy sklep

  225. Avatar
    Education Overseas 7 months later:

    Good blog and I liked it.

  226. Avatar
    Los Angeles Holiday 7 months later:

    Why not enable feed (RSS) on you blog. It would be nice

  227. Avatar
    Future Technology 7 months later:

    Resources like the one you mentioned here will be very useful to me

  228. Avatar
    ricky 7 months later:

    It is very informative.But one thing i clarify from you. How do you deal seo with Spam in blog comments? I genuinely hate it, It wastes my time and I hate dealing with it each day.

  229. Avatar
    Designer Jewelry 7 months later:

    Our jewelry designer Tom Babilla has taken the designer jewelry world by surprise. What is even more interesting is that all the collections are handcrafted and require great ability to finally give a good finish.

  230. Avatar
    John 7 months later:

    Sounds like OOP to me, I personally dislike having to code it myself.

    ~John

  231. Avatar
    Ateeq 7 months later:

    Awesome blog, i love it. I have subscribed to you my friend. Keep the good work up your getting there hehe!

    Technology and Blogging Tips Thanks!!

  232. Avatar
    Ateeq 7 months later:

    Good keep it up my friend!

  233. Avatar
    Use Ful Toolz 7 months later:

    Hi, are you comparing your self with google, I’ve saw some other topics like this on different forums but Have had a great fight with peoples there.

    discussing on same topics, I think google is pretty big company to compare with.

  234. Avatar
    ricky 7 months later:

    What is even more interesting is that all the collections are handcrafted and require great ability to finally give a good finish. seo

  235. Avatar
    craigslist tampa 7 months later:

    This looks absolutely perfect.I definitely agree with what you stated. Your explanation is certainly the easiest to understand about dependency injection. craigslist tampa

  236. Avatar
    http://www.magicsecrets.info 7 months later:

    its a very very gud thing for me because i have need this.. thanks for very informaitve post its nice i like it

  237. Avatar
    http://crazyfreepclaptop.com 7 months later:

    its a nice blog i like it u done the gud job

  238. Avatar
    http://www.youtube.com/watch?v=C0QkQY9CQ8w 7 months later:

    its a very very gud thing for me bethanks for very informaitve post its nice i like itcause i have need this..

  239. Avatar
    Power4Home 7 months later:

    I always use PHP because I think it is much more easier to use. For example, in this site Power4home , I used Php

  240. Avatar
    Greendiyenergy 7 months later:

    I forgot to mention that php is also better because it is much more efficient to use and the accessibility is awesome. On more example is this greendiyenergy

  241. Avatar
    posterrahmen 7 months later:

    I really like this new version. Wanna support for this for further development. I had some good command on the Arabic language. So I can satisfy well with this blog.

  242. Avatar
    Mike 7 months later:

    I agree with PHP definitely being easier to use, but this info is still very helpful.

  243. Avatar
    W-SEO 7 months later:

    PHP is too easy and not many functionality

  244. Avatar
    Computers Shops 7 months later:

    Resources like the one you mentioned here will be very useful to me

  245. Avatar
    kontakt 7 months later:

    this post is asome

  246. Avatar
    LV belt 7 months later:

    LV belt, LV belts, LV belts for men, LV Mens belts.
    Some actually seem like they are created with space creatures – not real women – in mind. But this fall, designers rolled out a multitude of great wearable looks.

  247. Avatar
    lily 7 months later:

    thank you

  248. Avatar
    Combat Pack 7 months later:

    Very interesting, thanks for sharing!

  249. Avatar
    rowery 7 months later:

    This looks absolutely perfect. All these tinny details are made with lot of background knowledge and it is very usefull. Thanks. I like your writing style, don’t change!

  250. Avatar
    blood sugar levels 7 months later:

    Thanks for this great post. Read about blood sugar levels.

  251. Avatar
    health symptoms 7 months later:

    Thanks for this post. Read about health symptoms.

  252. Avatar
    Judi 7 months later:
  253. Avatar
    Judi 7 months later:
  254. Thanks for this article…really useful!

  255. Avatar
    Sklep komputerowy 7 months later:

    Thx!

  256. Avatar
    Designer Jewelry 7 months later:

    Fantastic post. Bookmarked this site and emailed it to a few friends, your post was that great, keep it up.

  257. Avatar
    kidney infection symptoms 7 months later:

    Thanks for sharing this useful post. Read about kidney infection symptoms.

  258. Avatar
    Frontierville Cheats 7 months later:

    Php is always good but the learning curve is steep. right? I am a webmaster of Frontierville Cheats so I have a bit of a background.

  259. Avatar
    laptop computers 7 months later:

    BillingModule and BillingServiceFactory both extend AbstractModule and do the same binding. Is this necessary to make things work?

  260. Avatar
    Realizare Site Web 7 months later:

    Fantastic post. Bookmarked this site and emailed it to a few friends!

  261. Avatar
    Realizare Magazin virtual 7 months later:

    Thanks for sharing this useful post.

  262. Avatar
    Servicii Web Design 7 months later:

    Good job!

  263. Avatar
    Creare Magazin Online 7 months later:

    Interesting post man!

  264. Avatar
    Promovare Web Site 7 months later:

    I like all informations from your blog!

  265. Avatar
    Servicii Web Design Iasi 7 months later:

    Best texts!

  266. Avatar
    dupont lighter 8 months later:

    dupont lighter, dupont lighters, st dupont lighter, s.t. dupont lighters. Great post,just as Great belts Sale time,you will enjoy the shopping time by belts Sale online store,and buy belts from belts Sale online store. Price Guarantee, sale now.time limited.seize the chance.

  267. Avatar
    gucci wallet 8 months later:

    gucci wallet, gucci wallets, mens gucci wallet, women gucci wallet.
    Price Guarantee, sale now.time limited.seize the chance.

  268. Avatar
    Hermes belt 8 months later:

    Hermes belts, Elegant Hermes belt, Fashion Hermes belts for men, Hermes mens belt.
    Great post,just as Great belts Sale time,you will enjoy the shopping time by belts Sale online store,and buy belts from belts Sale online store.

  269. Avatar
    Men’s belts 8 months later:

    Men’s belts, LV men’s belts, Fashionable Gucci men’s belts, Attractive style Hermes men’s belts.
    This florist in Kensal Rise is an olfactory sensation, overflowing with flowers, foliage and stacks of ancient-looking vases and crockery. It all looks as if Vicky, the owner, has picked the flowers fresh from the meadows that day.

  270. Avatar
    LV belt 8 months later:

    LV belt, LV belts, LV belts for men, LV Mens belts.
    Some actually seem like they are created with space creatures – not real women – in mind. But this fall, designers rolled out a multitude of great wearable looks.

  271. Avatar
    DM800 8 months later:

    The Haizhouwan fishing ground, one of the eight largest fishing grounds in China, has more than 20 different kinds of fish and shrimps anda dozen different kinds of shellfish

  272. Avatar
    Caleb "Muscles" Anthony 8 months later:

    Nice Blog and Article. This is some indepth info.

  273. Avatar
    supplynflshop 8 months later:

    so good post i like it china nfl jerseys

  274. Avatar
    www.hotwatches.co.uk 8 months later:

    Not sure what these other posts are about but I am grateful for the info on Dependancy Injection. Wil watch out for future posts as I am trialing it on my Designer Watches website for ladies and gentlemen. Thanks again.

  275. Avatar
    Expert Coding 8 months later:

    I like your clean code for dependency injection inversion also I learn to write good code using your samples. what will be the code in case of singleton instead of factory patterns.

    Summer Dresses | Sports Discussion | Submit URL | Articles Writing | Pakistan Affairs

  276. Avatar
    exchange rate 8 months later:

    Very nice.

    I agree with you.Good Article by the way, I will be forwarding it onto my boss.

    Thanks!

  277. Avatar
    thrive.seo 8 months later:

    Nice post. Well written and interesting. Thanks for sharing the information.

  278. Avatar
    Mesothelioma 8 months later:

    Substantially, the article is really the best on this laudable topic. I concur with your conclusions and will eagerly look forward to your future updates. Just saying thank you will not just be enough, for the wonderful lucidity in your writing. I will instantly grab your rss feed to stay abreast of any udates. Gratifying work and much success in your business endeavors.

  279. Avatar
    best seo tips 8 months later:

    Thanks to all of them for making startups possible. And, most importantly ,So, there you have it. As fun as it has been to joke about it.

  280. Avatar
    pandora charms 8 months later:

    Hi there i like your unique site, I wuold be very honored if you would want me to write a review on your awesome work on my Blog would you be ok with that?

  281. Avatar
    Akcesoria rowerowe 8 months later:

    Brilliant post! It created enough of a stir for people to post replies on their blogs leading to valuable insight into various frameworks. Now my DI framework usage is clean, simple and does wonders. Thanks, it really made my day!

  282. Avatar
    Urdu Stories 8 months later:

    Very informative post thanks for the effort you have put into this.

  283. Avatar
    Used furniture stores 8 months later:

    Of course Guice seems excessive and the example with two units and a specific scope and life. What if some of the units need to be created by HttpRequest, some are created each time new and some are unique? Are you going to write a factory for each area? I think improvement would be a good solution. In fact, many schools didn’t care about the curriculum and just went with their own rules.

  284. Avatar
    crazy_dad 8 months later:

    Nice post, but it’s too much spam in comments.

  285. Avatar
    <a href="http://deseneonline.org">Desene online</a> 8 months later:

    Thank you very much Great post…thanks for share this

  286. Avatar
    Desene online 8 months later:

    Thank you very much Great post…thanks for share this

  287. Avatar
    usi 8 months later:

    nice share

  288. Avatar
    Sergio Luis 8 months later:

    This was exactly what i was searching for. Have been fighting for a while to do this, thanks for have posted

    High Weeds – All about Marijuana

  289. Avatar
    Premium WP Themes 8 months later:

    I think these frameworks are great tools. But I also think you should carefully restrict how and where you use them.

  290. Avatar
    Free Full Download 8 months later:

    Very helpful,thank you so much for this great article..I interested Injections..

  291. Avatar
    Betalningsanmärkning 8 months later:

    Mvc framework in asp has caused some quite advances issues for our programmers. Dependencies include controller, views and more. We have been successful at implementing it, at a quite high price though. It takes some time to get used to the dependency inversion model.

  292. Avatar
    Get A Prepaid Credit Card Today 8 months later:

    Get the best Prepaid Credit Card to fit your needs. Everyone is approved with out any credit checks or bank accounts needed.

  293. Get the best Prepaid Credit Card to fit your needs. Everyone is approved with out any credit checks or bank accounts needed.

  294. Avatar
    Best Price HQ 8 months later:

    Thanks for the code uncle Bob

  295. Avatar
    demimore 8 months later:

    Awesome job Uncle bob:)

  296. Avatar
    claudia webb 8 months later:

    Very informative post thanks for the effort… :)

  297. Avatar
    anti facebook 8 months later:

    This was exactly what i was searching for. Have been fighting for a while to do this, thanks for have posted

  298. Avatar
    marketing 101 8 months later:

    very interesting. I will bookmark this article, and I will read it carefully

  299. It helped me with ocean of awareness so I really consider you will do much better in the future.

  300. Avatar
    Alex Cruz 8 months later:

    Inversion of Control (IoC) means that objects do not create other objects on which they rely to do their work. Instead, they get the objects that they need from an outside source (for example, an xml configuration file).

    Dependency Injection (DI) means that this is done without the object intervention, usually by a framework component that passes constructor parameters and set properties.

  301. Avatar
    Mothers Day Flowers UK 8 months later:

    I use structure map to auto wire my dependencies and can usually get away with 10 to 20 lines of code.

  302. Avatar
    chanel purses for cheap 8 months later:

    i like your things very much ,very deep, so nice

  303. Avatar
    coach purses for cheap 8 months later:

    i like your articles, this is good post ,good blog

  304. Avatar
    lopoca 8 months later:

    Well worth the read. Thanks for sharing this information. I got a chance to know about this.

Comments