Francis Cianfrocca
8/13/2006 1:26:00 PM
On 8/13/06, Bob Hutchison <hutch@recursive.ca> wrote:
> > "Finally, a minor, almost a footnote, issue. I miss polymorphism.
> > In particular, I miss polymorphic constructors."
> >
> > but Ruby does have polymorphism. I guess he means "method
> > overloading" (which can be partially mimicked with default arguments).
What I find myself becoming more and more comfortable with is passing
single hashes to methods that take more than one argument, and single
arguments whenever possible. (And yes, I started doing this long
before the recent thread on functional programming :-), much of
Net::LDAP works this way). I find this to be a perfectly natural
alternative to polymorphic method signatures (even though the Python
syntax for this technique is better than Ruby's).
As far as Tim's polymorphic constructors go, I also find myself
avoiding constructors as much as possible in the first place. If you
have initial state in an object, that means it's been designed (or
not-so-designed as the case may be) in a non-composable way. My recent
Ruby code has almost no inheritance and module mixins all over the
place.