From: Edgardo Hames Date: 2005-07-27T04:05:35+09:00 Subject: Re: Abstract class or interface? On 7/22/05, Jim Weirich wrote: > > EdUarDo said: > > Hi all again :), > > > > How could I implement this model? > > > > Window <>--------------------- Button > > ^ > > | > > | > > ----------------- > > | | > > BigButton LittleButton > > > > > > Being 'Button' an abstract class or an interface. > > I mean, how do I define an interface? Must I use modules? > > If Button is a like a Java interface (i.e. no behavior), then you don't > need one in Ruby. Just implement BigButton and LittleButton with > compatible methods. > > If there is shared code in Button, then you can (1) create a class Button > and inherit from it in BigButton and LittleButton, or (2) Create a Button > module and include it in both Big and Little Buttons. > Some time ago, I posted a similar problem. Check the following link: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/127973 Cheers, Ed -- Encontr� a "Tu psic�pata favorito" http://tuxmaniac.blogspot.com Thou shalt study thy libraries and strive not to reinvent them without cause, that thy code may be short and readable and thy days pleasant and productive. -- Seventh commandment for C programmers