home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / cplus / 20020 < prev    next >
Encoding:
Text File  |  1993-01-28  |  7.0 KB  |  176 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!news.univie.ac.at!scsing.switch.ch!univ-lyon1.fr!ghost.dsi.unimi.it!rpi!gatech!darwin.sura.net!sgiblab!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
  3. From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
  4. Subject: Re: MI vs. SI
  5. Message-ID: <1993Jan27.163934.27255@ucc.su.OZ.AU>
  6. Sender: news@ucc.su.OZ.AU
  7. Nntp-Posting-Host: extro.ucc.su.oz.au
  8. Organization: MAXTAL P/L C/- University Computing Centre, Sydney
  9. References: <1993Jan20.022321.18020@borland.com> <1993Jan21.093918.3738@fmrco.uucp> <mg.727630597@elan.princeton.edu>
  10. Date: Wed, 27 Jan 1993 16:39:34 GMT
  11. Lines: 163
  12.  
  13. In article <mg.727630597@elan.princeton.edu> mg@elan (Michael Golan) writes:
  14. >pandrews@lovat.fmrco.com (Paul Andrews) writes:
  15. >>Totally agree. Why oh why oh why (:-)) do folks have such a downer on MI? 
  16. >
  17. >Because
  18. >1) Most implementations are buggy. Maybe all those compiler writers are
  19. >   idiots. Maybe the idea too complex and not well understood/documented.
  20.  
  21.     The biggest problem in C++ have nothing to do with MI,
  22. but to do with the type system. Next perhaps, templates and
  23. exceptions. These are respectively the oldest and newest features
  24. of the language.
  25.  
  26. >2) MI is hard to implement, hard to understand, hard to use correctly
  27.  
  28.     I dont have much trouble understanding it, and my compiler
  29. seems to implement it faultlessly. Its main flaw is something
  30. trivial: it cant determine whether a class is abstract or concrete
  31. correctly. The fault is due to poor wording in the ARM.
  32.  
  33. >3) MI can add bugs that are hard to detect
  34.  
  35.     So can pointers.
  36.  
  37. >4) MI lead to bad design, where people make one class into 3 (inhereting
  38. >   from two smaller classes), just so that (1) and (2) could possibly be used
  39. >   independently, even when this is not likely or important
  40.  
  41.     Seems like a good idea to have one class for each fundamental
  42. concept---even if you are not sure if the concepts will be used
  43. independently.
  44.  
  45.     After all, combining two such classes to make a new
  46. one is trivial with MI. Why burn your boats?
  47.  
  48. >5) MI is commonly used as a hack to combine incompatible classes that 
  49. >   are badly designed to begin with. This might be nice and good in the 
  50. >   short-run, for older C++ classes designs. It is most likely bad in the 
  51. >   long run.
  52.  
  53.     If this is common use, then more education is needed on
  54. how to use MI well. In fact, on how to use inheritance at all.
  55.  
  56. >6) They were mostly needed before the templates-era, when classes where used
  57. >   in implementing template-concepts, e.g. when a class had to be derived
  58. >   from LIST to be on the list. Then, when you wanted to collect some
  59. >   functionality on a list, you had to use MI. You still have to do so,
  60. >   if your "LIST" is some complex class, that *combines* a collection-
  61. >   mechanism with other functionality. Most such designs are bad, and 
  62. >   using MI instead of fixing the design is a bad idea.
  63.  
  64.     Sure, but this is spurious: using SI in the LIST situation
  65. is equally bad because in both cases you have to use downcasting.
  66.  
  67. >7) The complications to the language far out-weight the benefits, and it
  68. >   seems to have no end in sight. See dynamic_cast<Ouch>(Arr)
  69.  
  70.     I dont agree. Perhaps using MI properly requires a major
  71. paradigm shift, in particular, away from the Smalltalk Object 
  72. Heirarchy which is not suitable for C++.
  73.  
  74. >8) People abuse SI. I have seen many abstract classes with a field "type",
  75. >   which is set by each derived class and is checked at both levels.
  76. >   I consider this "cheating". 
  77.  
  78.     Yes, indeed, such a mechanism cannot be considered subclassing,
  79. and is best handled with discriminated unions wherever possible.
  80.  
  81. >   The escape from such bad design is with MI,
  82. >   and I don't like it. Sure, you can tell me not to use/buy/touch such 
  83. >   code, but in the real world we have to compromise. Call us "Nazis", for
  84. >   we would like to force you into "good design" by limiting your options.
  85. >   This might hurt the super-smart designer, but improve the average programmer
  86. >   productivity. And yes, we are concerned with the later. The former can
  87. >   find a smart way to overcome the limits anyway, when required.
  88.  
  89.     I dont understand your argument: you first say the 'escape'
  90. from bad design is to use MI, then say you dont like it?
  91.  
  92.     Why not just teach programmers how to use MI properly?
  93.  
  94. >    
  95. >You claim that the NIH lib would be better off with MI, and that this is
  96. >"clear". I challenge you to a battle of wits (The princess's bride:-).
  97.  
  98.     NIH from the sound of it would be better of it is simple
  99. didn't exist. I dont think such a monolithic monstrosity can be
  100. fixed. Just dont use it.
  101.  
  102. >Show us an example! Many people in this group have been claiming for some time
  103. >now, that they are yet to have seen code where MI is needed when the 
  104. >classes are correctly designed (w/templates) from scratch. 
  105.  
  106. >The last example on the net was a bank account class, from which credit and
  107. >debit accounts were derived, and then MI was used to combine their functions.
  108. >This is a typical bad example. How are the accounts stored on the disk?
  109.     
  110.     Irrelevant: that question can be asked of any class.
  111.  
  112.     No I take it back: in fact MI provides an excellent
  113. (user controlled) idiom to allow easy storage to disk.
  114.  
  115. >wouldn't the code as a whole be shorter and easier to understand if
  116. >these where combined into one class? 
  117.  
  118.     No, its better to encapsulate the smallest possible
  119. independent units without going completely overboard and deciding
  120. that one function is the smallest functional unit :-)
  121.  
  122. >Only when real code is presented, to
  123. >achieve a real task, can we truely compare such approaches.
  124.  
  125.     I'm working on a 'real' example. Please wait. So far
  126. the idea is for a mini-database (no, not object oriented :-)
  127. with device independent screen access and windows. 
  128. It does take a few lines of code to make such a thing work.
  129.  
  130. >
  131. >No doubt someone will tear this posting apart. Each point will be attacked
  132. >independently. 
  133.  
  134.     :-)
  135.  
  136. >I am sure I will be flamed for my own stupidity for not 
  137. >understanding the simple concepts behind MI, which are so obvious. 
  138.  
  139.     No. Almost no-one understands how to use MI properly.
  140. You will not be flamed. Your position is supported by prominent
  141. academics.
  142.  
  143. >You will
  144. >also tell us that soon, soon, MI will be implemented perfectly, and that you
  145. >have already used it in 100k lines project and it was indispensable.
  146.  
  147.     Yes. I've done a project where MI was mandatory.
  148. (Because the linkage was dynamic: absolutely no possibility
  149. of downcasting.)
  150.  
  151. >Never the less, many people will remain steadfast in their believes in
  152. >many of the above claims. We don't believe this complexity is necessary,
  153. >and we would like a shorter reference manual!
  154.  
  155.     So just dont use MI. You dont have to.
  156.  
  157. >
  158. >Of course, we lost the battle a long time ago. 
  159.  
  160.     Yes.
  161.  
  162. >Lets design ++C.
  163. >
  164. > Michael Golan
  165. > mg@cs.princeton.edu
  166.  
  167.     Interestingly, I read ++C as 'incremental C'. 
  168. And you can get this with mixins and no other way
  169. (short of delegation=dynamic inheritance)
  170.  
  171. -- 
  172. ;----------------------------------------------------------------------
  173.         JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
  174.     Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
  175. ;------ SCIENTIFIC AND ENGINEERING SOFTWARE ---ph:  2 799 8223 --------
  176.