I believe most Rubyists walked away from DI by the time Jamis Buck gave this presentation on Net…
Fabio Akita

Hey Fabio,

It’s so unfortunate that people *still* refer to this talk, even though 8 year have passed and we learned a lot over that time. I actually re-watched this talk a couple of days ago…here’s what people probably don’t remember:

  • Jamis tried to port IoC *frameworks* from Java, by following similar, heavy patterns, like class factories, and complex object-building pipelines. This ended up horribly bad, which he openly admitted in his talk. And that’s fine. We don’t need that in Ruby
  • Jamis made a mistake by trying to use complex DI patterns *in a library* (Net::SSH), which is an overkill
  • Jamis did not reject DI at all, he said it’s a good choice for complex cases like…a web application!

Now this has been intepreted as “DI is wrong, we don’t need it”. That’s bad, DI is great, and very simple in Ruby. I really hope we’ll “recover from recovering from enterprise” as I believe the whole ecosystem would benefit if people were open to DI and didn’t react negatively to the word “container” :)

I’ve been using DI with manual object construction for ~3 years with great success, last year I finally realized that I do want to use a container to reduce boilerplate. Which I did, and it works great. I’ve built a couple of web apps using this technique (a rails app and a dry-web app) and I’ve been very happy with the results.



Show your support

Clapping shows how much you appreciated Piotr Solnica’s story.