News for hackers. Stuff that matters.
Re:Java Doesn't Need to Be So Bad by hello_moto on Thursday December 08, 2011 @05:54PM (#3331568)
DI is useful in the situation where you'd like to mock 3rd-party web-service (that usually don't have test environment themselves).

e.g.: Integration with Twitter. If you don't mocked Twitter client API, you won't be able to write unit-test (or someone will make a lot of excuses of how hard to write unit-tests).

You can work-around DI with having a factory/template method that you'd override or whatnot but that situation won't work 100% in all situations. You may end up writing more code.

YMMV. Use it when you absolutely need it.

There are no comments on this comment yet.