P
PerfectDayToChaseTornados
Hi All,
I am a Java developer of many years & just starting to get into Ruby (&
really enjoying it!). However I am used to 'coding by contract' using
interfaces. This is especially great when using dependency injection
(usually via Spring). It makes testing very easy, as 'mocks' can be written
simply & then plugged in. I know that there isn't an equvalent for an
interface in Ruby, but is there a pattern which would typically be used? I
was wondering whether to create Modules in place of my interfaces & provide
them with methods which throw Exceptions, thus forcing them to be overrriden
in the classes that include them? Also how does one manage dependency
injection in Ruby? Is there a good framework/library/pattern typically used
for this, or are there good 'Ruby reasons' not to use DI?
Many thanks
I am a Java developer of many years & just starting to get into Ruby (&
really enjoying it!). However I am used to 'coding by contract' using
interfaces. This is especially great when using dependency injection
(usually via Spring). It makes testing very easy, as 'mocks' can be written
simply & then plugged in. I know that there isn't an equvalent for an
interface in Ruby, but is there a pattern which would typically be used? I
was wondering whether to create Modules in place of my interfaces & provide
them with methods which throw Exceptions, thus forcing them to be overrriden
in the classes that include them? Also how does one manage dependency
injection in Ruby? Is there a good framework/library/pattern typically used
for this, or are there good 'Ruby reasons' not to use DI?
Many thanks