Ruby on Rails
Wednesday, March 26, 2014
Hi Rails developers,
I would appreciate some assistance. Please study the following code and provide your reasoning for whether you agree or disagree with the following statements.
I understand the code is not specific to Rails, however I am specifically interested in Rails developer's perspective. Thanks!
car.rb
class Car
def initialise(engine)
@engine = engine
end
def start
@engine.start
end
end
engine.rb
class Engine
def start
puts 'Engine started'
end
end
- Car is not dependent on, and therefore not coupled to Engine
- Car is dependent on an object that responds to "start"
- Car may or may not be initialised with an Engine object
- Car uses constructor-based dependency injection
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/b668de93-be86-4b3c-a223-be34d1d2551b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment