From: Dave Thomas Date: 2002-02-04T02:48:09+09:00 Subject: Re: Subclassing vs Subtyping (partly OOP vs FP) Lewis Perin writes: > > http://okmij.org/ftp/Computation/Subtyping/ > > The above was posted ten days ago and so far the silence has been > fairly deafening. I found the site Robert Feldt mentions quite > compelling and was hoping that some true Ruby adepts would have a lot > to say about it. To be honest I was not particularly stirred by the article. It became apparent during the lead-in that the choice of basing a Set on a Bag was wrong, and everything else fell out from that (it's the old Circle < Ellipse or Ellipse < Circle debate). It's also not to relevant to Ruby, as Ruby's types are based on implicit protocols, not classes. In Ruby, you typically sublcass to get behavior, not interface, so these issues just don't arise. You might choose to delegate a Set to a Bag, or you might choose to have a general collection mixin tha both Set and Bag could use, but you'd be unlikely to subclass one from the other. It's a difficult habit to break. When you're used to C++ and Java, it seems natural to think of everything in terms of class hierarchies. But after programming in Ruby for a while, I find that I'm writing fewer and fewer deep class trees. Dave