On Nov 6, 11:34=A0am, Michael Libby <michael.c.li... / gmail.com> wrote:
> On Thu, Nov 6, 2008 at 10:38 AM, Curator1 <rsilv... / gmail.com> wrote:
> > Repeating: Superclasses are based on common conceptual denominators
> > (CCD)not on the number of data members.
>
> Agreed.
>
> [following code sample shortened for clarity]
>
>
>
> > class ClosedPolygon
> > end
>
> > class RegularPolygon < ClosedPolygon
> > end
>
> > class Square < RegularPolygon
> > end
>
> > class Rectangle < ClosedPolygon =A0# See!!! =A0CCD's properly
> > end
>
> > class Pentagon < RegularPolygon
> > end
>
> > class IsoTriangle < ClosedPolygon
> > end
>
> > class EquiTriangle < RegularPolygon
> > end
>
> Can we take the principal of common conceptual denominators further by
> using modules in addition to superclasses?
>
> class Rectangle < ClosedPolygon
> end
>
> class Square < Rectangle
> =A0 include RegularPolygon
> =A0 def initialize
> =A0 =A0 =A0super()
> =A0 =A0 =A0check_sides_are_equal_length #defined in RegularPolygon
> end
>
> -Michael Libby

Yes.  Modules offer all sorts of exciting possibilities if behavior
can be coded generically enough with the subclasses providing key
operations that enable the mixin. It's one aspect of Ruby that I'm
learning to love. Definitely superior to interfaces, as say in Java.
E.g. the relationship of Sets and Enumerable is one example.

I didn't mean to be pedantic in the prior post.  It's just I was
confronted recently with a complicated hierarchy where someone used
all sorts of principles to derive the hierarchy except the right one.
We were in Java and so the above came out in single-inheritance
style.  Your module comment is well-received.