home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / cplus / 16632 < prev    next >
Encoding:
Text File  |  1992-11-20  |  3.3 KB  |  75 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
  3. From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
  4. Subject: Re: Should I use a generic object which all others inherit from
  5. Message-ID: <1992Nov20.133441.27425@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: <3762@news.cerf.net> <1992Nov17.190821.18348@informix.com>
  10. Date: Fri, 20 Nov 1992 13:34:41 GMT
  11. Lines: 62
  12.  
  13. In article <1992Nov17.190821.18348@informix.com> cshaver@informix.com (Craig Shaver) writes:
  14. >In article <3762@news.cerf.net> hlf@nic.cerf.net (Howard Ferguson) writes:
  15. >>I am working on the early stages of design on an embedded C++
  16. >>project. One of the decisions which we will have to make in the
  17. >>near future is whether to make all of the objects inherit from 
  18. >>onie generic object at the top of the tree or to go for the forest 
  19. >>approach. 
  20. >>
  21. >
  22. >You have some of the benefits of OOP in mind, such as inheritance, reuse, 
  23. >and information hiding.  Then if you are willing to take small dings in
  24. >performance go all the way and use the tree approach as pioneered by
  25. >Smalltalk.  
  26.  
  27.     Please do NOT do this. This approach requires dynamic type
  28. checking which cannot be done in C++ (yet). IMHO the object model
  29. of Smalltalk is totally inappropriate in C++. You should do exactly
  30. the opposite, IMHO. C++ now has multiple inheritance (MI), use it.
  31.  
  32. >I recently saw a review of the toy code that comes with the
  33. >borland compiler.  The article's author commented that the tree type
  34. >libraries were "passe" because of templates.  What a stupid thing to say!
  35.  
  36.     I dont agree and neither does Borland (I assume) since they
  37. provided an updated version using templates. The original 'object'
  38. version is one of the worst pieces of code I've ever seen (sorry
  39. Borland, twas the best that could be done with only single inheritance
  40. and no templates I suppose).
  41.  
  42. >
  43. >One of the big wins of OOP is reuse.  By using an inheritance structure
  44. >you can reuse existing code and do incremental development.  
  45.  
  46.     By using a 'tree' structure you can only do 'layered development'.
  47. To do proper 'incremental' development you must use mixin techniques,
  48. which require abstract virtual bases.
  49.  
  50. >Related and
  51. >unrelated classes can be used in the same context where a similar protocol
  52. >is enforced.  
  53.  
  54.     Absolutely not in C++. C++ unlike Smalltalk is strongly typed,
  55. the only support for 'protocol' based reusability is with templates.
  56. (My tagged pointer proposal extends this considerably).
  57.  
  58. >
  59. >I have to think some of the people involved with C++ have no idea what the
  60. >basis of OOP really is.  They are simply using C++ as an improved C.
  61.  
  62.     Nothing wrong with that. C compatibility is one of the principal
  63. guidelines of the standardisation people. Using C++ as an ADT language
  64. is a good use of C++ in my opinion, that is, as C with user defined
  65. types.
  66.  
  67.     If you really want dynamic object orientation, C++ is probably
  68. not the best language to use. Why not use Smalltalk in the first place?
  69.  
  70. -- 
  71. ;----------------------------------------------------------------------
  72.         JOHN (MAX) SKALLER,         maxtal@extro.ucc.su.oz.au
  73.     Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
  74. ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
  75.