home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / ada / 3239 < prev    next >
Encoding:
Internet Message Format  |  1992-11-09  |  4.7 KB

  1. Xref: sparky comp.lang.ada:3239 comp.object:4181
  2. Path: sparky!uunet!ogicse!emory!swrinde!sdd.hp.com!ux1.cso.uiuc.edu!cs.uiuc.edu!johnson
  3. From: johnson@cs.uiuc.edu (Ralph Johnson)
  4. Newsgroups: comp.lang.ada,comp.object
  5. Subject: Re: OOD, Ada, and Inheritance
  6. Message-ID: <BxGpxt.FDw@cs.uiuc.edu>
  7. Date: 9 Nov 92 18:56:16 GMT
  8. Article-I.D.: cs.BxGpxt.FDw
  9. References: <mmaccorm.47@fox.nstn.ns.ca> <2169@snap> <1992Nov9.145313.18741@cis.ohio-state.edu>
  10. Organization: University of Illinois, Dept. of Comp. Sci., Urbana, IL
  11. Lines: 71
  12.  
  13. weide@elephant.cis.ohio-state.edu (Bruce Weide) writes:
  14.  
  15. >The questions about inheritance in Ada, and especially the responses
  16. >about inheritance being "simulated" in Ada, are interesting.  Those
  17. >who are REALLY interested in this issue would do well to consider
  18. >whether inheritance (as commonly practiced in OO languages) is
  19. >something you ought to want; see the paper by J.P. Rosen in the Nov
  20. >1992 issue of Comm of the ACM.
  21.  
  22. I have read Rosen's paper several times, and I dislike it more
  23. every time I read it.  The fact that inheritance *can* be misused is 
  24. no argument against it.  Rosen was putting up a straw man -- people 
  25. in the C++ and Smalltalk community place great value in components and
  26. do *not* believe that inheritance is the only, or even the primary,
  27. way to reuse software.  I suppose you could get that opinion from
  28. reading papers, since a lot of papers on software reuse from an OO 
  29. point of view are a bit one-sided and don't give a complete picture,
  30. but you can't get that opinion if you look at the kind of systems
  31. that are built.  For example, the GNU C++ classes rely almost
  32. entirely on reuse by composition.  This is one of its weaknesses,
  33. in my opinion, because the best reusable frameworks will carefully
  34. trade off the extensibility and higher coupling of inheritance with
  35. the ease of use and run-time flexibility of composition, but it
  36. certainly shows that people in the C++ community value composition.
  37. InterViews or the latest version of Model/View/Controller from ParcPlace
  38. ARE very good examples of how to combine inheritance and composition to
  39. make something that is much more powerful and easy to use than either
  40. technique could provide on its own.
  41.  
  42. Just as serious a problem with Rosen's paper is the opinion that
  43. polymorphism is optional and can be done by hand when needed.  We
  44. could say the same thing about control structures, of course.  In
  45. practice, lack of language support for polymorphism will mean that
  46. people will not use it for little things, and will consider using
  47. it to be difficult and a technique to be used only for hard problems.
  48. In contrast, in C++ or Smalltalk polymorphism is so easy to use that
  49. it is almost bad design to ever use a case statement, and so programs
  50. are easier to extend.  Rosen seemed to contradict himself when he
  51. talked about why Ada 9X wanted to add support for polymorphism, so
  52. perhaps he doesn't really believe this, but was just trying to explain
  53. why Ada was designed the way it was.  Ada is 14 years old, so trying
  54. to justify it in terms of current software engineering practices seems
  55. pointless to me.  (Note: "justify" is not "analyze" or "critique".)
  56.  
  57. I've been pretty negative about his paper.  The thing I liked about
  58. his paper was his examples of designs that used inheritance
  59. that would probably be better of using composition.  He is right.
  60. There are several different ways of using inheritance, and I suppose
  61. some of the differences are just stylistic, and there might not be
  62. a right or wrong way, but I tend to agree with him that the examples
  63. he gave are bad examples, and that composition is a better way to
  64. solve those problems.  Where I disagree with him is his claim that
  65. the entire object-oriented community, or even the majority of it,
  66. thinks that these examples are good design.  Moreover, I disagree
  67. that his examples showed what is important about inheritance.
  68.  
  69. After 7 years of experience in building object-oriented systems, I
  70. think that polymorphic composition probably has a bigger impact on 
  71. program structure than inheritance, but I wouldn't want to give up 
  72. inheritance.  Some important design patterns that are based on inheritance 
  73. are template methods in abstract classes (which can be simulated by 
  74. generics in Ada), default implementation of abstract methods or overriding 
  75. standard templates for greater efficiency (which can't be), and use of 
  76. abstract classes to represent behavioral constraints on interfaces.  I 
  77. want to have inheritance in my programming languages.  I am perfectly 
  78. happy for someone to improve it or come up with new ways of doing the 
  79. same things, but standard composition is not a replacement for inheritance, 
  80. but is instead an addition.  (Or inheritance is an addition to composition,
  81. since composition was first.)
  82.  
  83. Ralph Johnson -- University of Illinois at Urbana-Champaign
  84.