comp.lang.ada
 help / color / mirror / Atom feed
From: sdd.hp.com!ux1.cso.uiuc.edu!cs.uiuc.edu!johnson@hplabs.hpl.hp.com  (Ralph Johnson)
Subject: Re: OOD, Ada, and Inheritance
Date: 9 Nov 92 18:56:16 GMT	[thread overview]
Message-ID: <BxGpxt.FDw@cs.uiuc.edu> (raw)

weide@elephant.cis.ohio-state.edu (Bruce Weide) writes:

>The questions about inheritance in Ada, and especially the responses
>about inheritance being "simulated" in Ada, are interesting.  Those
>who are REALLY interested in this issue would do well to consider
>whether inheritance (as commonly practiced in OO languages) is
>something you ought to want; see the paper by J.P. Rosen in the Nov
>1992 issue of Comm of the ACM.

I have read Rosen's paper several times, and I dislike it more
every time I read it.  The fact that inheritance *can* be misused is 
no argument against it.  Rosen was putting up a straw man -- people 
in the C++ and Smalltalk community place great value in components and
do *not* believe that inheritance is the only, or even the primary,
way to reuse software.  I suppose you could get that opinion from
reading papers, since a lot of papers on software reuse from an OO 
point of view are a bit one-sided and don't give a complete picture,
but you can't get that opinion if you look at the kind of systems
that are built.  For example, the GNU C++ classes rely almost
entirely on reuse by composition.  This is one of its weaknesses,
in my opinion, because the best reusable frameworks will carefully
trade off the extensibility and higher coupling of inheritance with
the ease of use and run-time flexibility of composition, but it
certainly shows that people in the C++ community value composition.
InterViews or the latest version of Model/View/Controller from ParcPlace
ARE very good examples of how to combine inheritance and composition to
make something that is much more powerful and easy to use than either
technique could provide on its own.

Just as serious a problem with Rosen's paper is the opinion that
polymorphism is optional and can be done by hand when needed.  We
could say the same thing about control structures, of course.  In
practice, lack of language support for polymorphism will mean that
people will not use it for little things, and will consider using
it to be difficult and a technique to be used only for hard problems.
In contrast, in C++ or Smalltalk polymorphism is so easy to use that
it is almost bad design to ever use a case statement, and so programs
are easier to extend.  Rosen seemed to contradict himself when he
talked about why Ada 9X wanted to add support for polymorphism, so
perhaps he doesn't really believe this, but was just trying to explain
why Ada was designed the way it was.  Ada is 14 years old, so trying
to justify it in terms of current software engineering practices seems
pointless to me.  (Note: "justify" is not "analyze" or "critique".)

I've been pretty negative about his paper.  The thing I liked about
his paper was his examples of designs that used inheritance
that would probably be better of using composition.  He is right.
There are several different ways of using inheritance, and I suppose
some of the differences are just stylistic, and there might not be
a right or wrong way, but I tend to agree with him that the examples
he gave are bad examples, and that composition is a better way to
solve those problems.  Where I disagree with him is his claim that
the entire object-oriented community, or even the majority of it,
thinks that these examples are good design.  Moreover, I disagree
that his examples showed what is important about inheritance.

After 7 years of experience in building object-oriented systems, I
think that polymorphic composition probably has a bigger impact on 
program structure than inheritance, but I wouldn't want to give up 
inheritance.  Some important design patterns that are based on inheritance 
are template methods in abstract classes (which can be simulated by 
generics in Ada), default implementation of abstract methods or overriding 
standard templates for greater efficiency (which can't be), and use of 
abstract classes to represent behavioral constraints on interfaces.  I 
want to have inheritance in my programming languages.  I am perfectly 
happy for someone to improve it or come up with new ways of doing the 
same things, but standard composition is not a replacement for inheritance, 
but is instead an addition.  (Or inheritance is an addition to composition,
since composition was first.)

Ralph Johnson -- University of Illinois at Urbana-Champaign

             reply	other threads:[~1992-11-09 18:56 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1992-11-09 18:56 Ralph Johnson [this message]
  -- strict thread matches above, loose matches on Subject: below --
1992-12-04 20:49 OOD, Ada, and Inheritance Bruce Weide
1992-12-04  8:54 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!darwin.sura.net!paladin.amer
1992-12-03 21:19 dog.ee.lbl.gov!overload.lbl.gov!agate!usenet.ins.cwru.edu!magnus.acs.ohio
1992-12-02 20:25 dog.ee.lbl.gov!network.ucsd.edu!usc!zaphod.mps.ohio-state.edu!cis.ohio-st
1992-12-02 14:58 pipex!bnr.co.uk!bnrgate!nott!cunews!cunews!knight
1992-11-20 20:28 klamath.cs.washington.edu!chambers
1992-11-17 20:37 dog.ee.lbl.gov!pasteur!agate!usenet.ins.cwru.edu!magnus.acs.ohio-state.ed
1992-11-16 15:09 eru.mt.luth.se!lunic!sunic!mcsun!uknet!comlab.ox.ac.uk!ajs
1992-11-16  8:48 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!darwin.sura.net!Sirius.dfn.d
1992-11-13 22:45 klamath.cs.washington.edu!chambers
1992-11-13 20:37 Bruce Weide
1992-11-11  4:20 sun-barr!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!darwin.sura.net!
1992-11-10 20:58 sun-barr!cs.utexas.edu!natinst.com!news.dell.com!milano!cobweb.mcc.com!br
1992-11-09 18:30 eru.mt.luth.se!lunic!sunic!lth.se!newsuser
1992-11-09 16:36 Jorge Luis Diaz-Herrera
1992-11-09 14:53 think.com!sdd.hp.com!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!elephan
1992-11-07 18:49 John Goodsen
1992-11-07  1:25 mole-end!mat
1992-11-06 20:13 John Goodsen
1992-11-06  9:00 agate!doc.ic.ac.uk!uknet!root44!hrc63!mrcu!paj
1992-11-05 19:20 David Emery
1992-11-05 19:09 saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!new
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox