|
|
|
|
|
by nbevans
4737 days ago
|
|
"IOC:
my_blah = container.resolve(Blah)" That's not IOC. That's service location. Which is only used at the "composition root" (look it up) in IOC. "In fact, pinject doesn't even mention tests in its documentation. Whew~ That's only the whole reason for using DI in the first place." No, testing accounts for just one of the more minor reasons to be using DI. |
|
In dynamic languages with no real 'private' members, the benefit is actually pretty minimal because you can assign mock service instances after the object is created.
eg.
vs. ...which means, there isn't a lot of point in using it, unless you're using an IOC container which gives you some other synergy bonuses like singletons, per thread and per request instances, configuration file driven implementation binding, etc.