views:

458

answers:

3

Does the fact that Rails have an MVC approach mean that is has dependency injection?

Or is there a reason that we don't talk about dependency injection in Rails?

If Rails does have dependency injection, what does it consist of?

+9  A: 

Dependency injection is usually unnecessary with Ruby. Jamis Buck blogged extensively about the reasons why. Well worth a read.

John Topley
Jamis was really saying that there's no need for the heavy-handed DI frameworks frequently in use with Java. He didn't say that it's unnecessary in Ruby - to the contrary, DI can be used in Ruby to reduce coupling and improve testability. It's just not AS necessary.
scottburton11
+2  A: 

Dependency Injection is a paradigm, so it exists in every object-oriented language.

Whether there are DI frameworks for Ruby - check this question

Bozho
A: 

I'd say that you don't need such a thing with ruby... but if you really want to, some people have workarounds.

marcgg