Ruby on Rails
Thursday, March 27, 2014
Hi, thanks for taking the time to respond.
On Thursday, 27 March 2014 03:16:03 UTC+11, Ruby-Forum.com User wrote:
-- I'm experienced with Ruby, but new to Rails. I'm familiar with RSpec.
Ruby certainly does make DI really, really easy.
Ruby also makes it really easy to test code without the need for IoC.
IoC offers other benefits aside from testability. One obvious example is loose coupling.
Loose coupling reduces the risk that changes impact seemingly unrelated areas of the system.
Ruby in itself cannot offer that benefit, nor can Rails.
Would you agree that regardless the language or framework, loose coupling is a valuable engineering practise?
If not, why not? If so, how do you accomplish loose coupling in Rails?
Look forward to your reply, thanks.
On Thursday, 27 March 2014 03:16:03 UTC+11, Ruby-Forum.com User wrote:
Matthew Riley wrote in post #1141041:
> I understand the code is not specific to Rails, however I am
> specifically
> interested in Rails developer's perspective. Thanks!
Perspective on what? As you demonstrate, Dependency Injection (DI) is a
really simple concept, with a really simple implementation, in dynamic
("Duck Typed") languages like Ruby.
Are you asking to verify what you have shown is "Dependency
Inject/Inversion of Control?" If so then sure it is.
Are you asking if Rails developers spend a lot of time worrying about
"Dependency Injection" or creating elaborate frameworks to support DI?
That would be a pretty resounding "NO".
Given that a high percentage of DI usage is related to testability, it
might do you good to look at one of the popular testing frameworks used
by Rails developers, for example:
https://github.com/rspec/rspec
You won't see a lot of talk in there about DI or IoC mumbo-jumbo. You'll
see the stuff that's actually important, like test doubles, mocks,
stubs, etc. Ruby is a dynamically typed language without all those pesky
static type dependencies. Take advantage of that in whatever way makes
sense.
--
Posted via http://www.ruby-forum.com/.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/ce549191-e534-4385-ab68-9cb1d9275a20%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment