Hacker News new | ask | show | jobs
by zupatol 4883 days ago
I agree with using IoC for different implementations, but I'm puzzled by those who want to use it everywhere, because it supposedly makes the code easier to test.

Guice is a nice IoC framework, but look at what they say on their website:

"Think of Guice's @Inject as the new new."

http://code.google.com/p/google-guice/

2 comments

Testing is kind of a side effect. When you design your code with IoC in mind, you naturally will create more logical separations and avoid tight coupling -- which in turn will make your code easier to test. (Source: I wrote Ninject. :)
If your code has a hard-static dependencies to web-service call, you can't test it easily (and repeatedly). Especially when the actual service is down.

If your code has a hard-static dependencies to DB call, you now have excuses not to write test against it because "it's hard to prepare the environment to do such things."

Not all projects are as small as a Todo-List written using Rails.

Medium-to-Large size projects with large DB schemas exist in which it will take hours to run your Rails tests: "testing-my-active-record-models-as-unit-tests"