[jdom-interest] Re: Interfaces? (was: W3 DOM support)

Alex Chaffee guru at edamame.stinky.com
Thu Sep 21 18:21:31 PDT 2000


Scanning old threads, specifically this one on whether Element et al
should be interfaces:

On Mon, Aug 07, 2000 at 09:32:10AM -0400, David W. Smiley wrote:
> > > And I'm not a big fan of subclassing.  I'd rather delegate.  To my mind,
> > > subclassing is a fragile, often requiring intimate knowledge of the
> > > source code and leaving oneself vulnerable to future revisions of the
> > > base classes.
> > 
> > Hear, hear!  Inheritance is OOP for the weak!  Delegation rules.
> 
>   Excuse me?  This statement suggests inheritance has no purpose.

Inheritance is syntactic sugar (like all OOP actually).  Delegation is
strictly more powerful than inheritance, since all inheritance buys
you is that you don't have to write

 int foo(int bar) {
   return parent.foo(bar);
 }

for all methods you neglect to implement yourself.  Plus, inheritance
has baggage like the abovementioned, and like forcing you to use a
single (inherited) implementation instead of allowing swapping
different implementations in and out.

Note that inheritance is not the same thing as polymorphism, which
rocks.  Inheritance = polymorphism + code sharing


-- 
Alex Chaffee                       mailto:alex at jguru.com
jGuru - Java News and FAQs         http://www.jguru.com/alex/
Creator of Gamelan                 http://www.gamelan.com/
Founder of Purple Technology       http://www.purpletech.com/
Curator of Stinky Art Collective   http://www.stinky.com/



More information about the jdom-interest mailing list