home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / cplus / 16508 < prev    next >
Encoding:
Internet Message Format  |  1992-11-18  |  2.5 KB

  1. Path: sparky!uunet!mcsun!sunic!hagbard!loglule!jbn
  2. From: jbn@lulea.trab.se (Johan Bengtsson)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Should I use a generic object which all others inherit from
  5. Message-ID: <5232@holden.lulea.trab.se>
  6. Date: 18 Nov 92 12:41:12 GMT
  7. References: <1992Nov17.190821.18348@informix.com>
  8. Organization: Telia Research AB, Aurorum 6, 951 75 Lulea, Sweden
  9. Lines: 46
  10. X-Newsreader: Tin 1.1 PL4
  11.  
  12. cshaver@informix.com (Craig Shaver) writes:
  13. : In article <3762@news.cerf.net> hlf@nic.cerf.net (Howard Ferguson) writes:
  14. : >I am working on the early stages of design on an embedded C++
  15. : >project. One of the decisions which we will have to make in the
  16. : >near future is whether to make all of the objects inherit from 
  17. : >onie generic object at the top of the tree or to go for the forest 
  18. : >approach. 
  19. : >
  20. :
  21. : An embedded system!  C++!?  JUST USE C!!!!
  22. : UNLESS ....
  23. : You have some of the benefits of OOP in mind, such as inheritance, reuse, 
  24. : and information hiding.  Then if you are willing to take small dings in
  25. : performance go all the way and use the tree approach as pioneered by
  26. : Smalltalk.  I recently saw a review of the toy code that comes with the
  27. : borland compiler.  The article's author commented that the tree type
  28. : libraries were "passe" because of templates.  What a stupid thing to say!
  29. : One of the big wins of OOP is reuse.  By using an inheritance structure
  30. : you can reuse existing code and do incremental development.  Related and
  31. : unrelated classes can be used in the same context where a similar protocol
  32. : is enforced.
  33.  
  34. Perhaps you would then kindly enlighten the rest of us:
  35.  
  36. If I go for the tree approach, with a base class MyObject inherited
  37. by all my classes, how am I going to reuse _your_ classes, which all
  38. inherit from class YourObject?  Multiple inheritance?  What
  39. if the protocol of my base class conflicts with your base class?
  40. How do I reuse tree-type libraries from several sources, each with
  41. it's own base class protocol?
  42.  
  43. Enforcing a common protocol (by inheritance) for all your classes,
  44. _hampers_ reuse of your classes by anyone except yourself.
  45.  
  46. Once a reference to an object has been passed as a generic
  47. object reference, for example into a collection, how do you (safely)
  48. call the actual methods of the objects (derived) class?
  49.  
  50. -- 
  51. --------------------------------------------------------------------------
  52. | Johan Bengtsson, Telia Research AB, Aurorum 6, S-951 75 Lulea, Sweden  |
  53. | Johan.Bengtsson@lulea.trab.se; Voice:(+46)92075471; Fax:(+46)92075490  |
  54. --------------------------------------------------------------------------
  55.