From: Christoph Rippel Date: 2001-01-26T12:40:04+09:00 Subject: [ruby-talk:9907] Re: 101 Misconceptions About Dynamic Languages "Reimer Behrends" wrote in message news:slrn96vftq.kgf.behrends@allegro.cse.msu.edu... ... [..] Sorry I thing may previous reply was a bit to cryptic and I misunderstood your design (your Polynomials have only one variable I believe). Given this I would rewrite your design [ ...] > class Polynomial < Ring > > def type > nil # Formal type, undefined > end > > # add the usual operations on polynomials here, dependent > # on the result of 'type'. > > end > > class ComplexPolynomial < Polynomial > > def type > Complex > end > > end as class Ring One = nil Zero = nil def +( r) end def -(r) end def :- Zero - self end def *(r) end end class Poly < Ring Coeff = Ring end Never mind the implementation details. If want more flexibility you can replace the class constants with class attributes (in this case probably unnecessary) def Ring.one end def Ring.zero end def Poly.coeff Ring end Note you should stick the arithmetic of Poly into a mixin ( this way you get more flexibility in terms of representation for example sparse polynomials come to mind). If you write this like this all your problems with the generative style should go away IMO .. [...] > Reimer Behrends Christoph