home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / cplus / 11307 < prev    next >
Encoding:
Internet Message Format  |  1992-07-21  |  2.4 KB

  1. Xref: sparky comp.lang.c++:11307 comp.object:2958
  2. Newsgroups: comp.lang.c++,comp.object
  3. Path: sparky!uunet!mole-end!mat
  4. From: mat@mole-end
  5. Subject: Re: The "has-a" relation in C++ ? How ?
  6. Message-ID: <1992Jul21.132202.20742@mole-end>
  7. Keywords: object,C++,has-a
  8. Organization: :
  9. References: <1992Jul20.212525.5081@dsg.tandem.com>
  10. Date: Tue, 21 Jul 1992 13:22:02 GMT
  11. Lines: 38
  12.  
  13. In article <1992Jul20.212525.5081@dsg.tandem.com>, narayan@aravali.everest.tandem.com (Pankaj Narayan) writes:
  14. > Books typically go over the "is-a" relationship in much detail, saying how
  15. > C++ has this great inheritance mechanism to support this sort of a
  16. > relationship.
  17.  
  18. > However, when it comes to the "has-a" relationship, they don't really talk
  19. > about or give implementation examples of how that is done in C++.  The
  20. > Coad/Yourdon OOD book talks a little about it, and says that it can be done
  21. > in a couple of ways, but does not give any substantial example.
  22.  
  23. > If you know of a book that does have a good example or description of this,
  24. > please e-mail me your comments.  
  25.  
  26. You do it the same way you do it in C: by members that represent the
  27. subsidiary objects, or by members that point to the other objects--in
  28. other words, you are back in the world of data structures.  The
  29. Structured Analysis/Structured Design people have made a very thorough
  30. study of the topic and any book that covers Data Modelling/Information
  31. Modelling should tell you all you ever wanted to know.
  32.  
  33. When I teach OO, I treat Inheritance as something `other than' a
  34. Relationship; it avoids confusion between the two things that seem to
  35. be of a different kind.  Inheritance is a relationship between two or
  36. more kinds of category into which a thing falls; other relationships
  37. are between two or more things (which occasionally may happen to be
  38. the same).  I've gotten great results by identifying Inheritance before
  39. I even start to _talk_ about Relationships; doing it in other ways led
  40. to students coming up with many wierd interpretations for Inheritance and
  41. many wierd class/relationship diagrams reflecting those interpretations.
  42. When I had them identify the likely Inheritance hierarchies in the problem
  43. before we even started to talk about relationships, they came up with
  44. workable class/relationship diagrams for the problem in a few minutes and
  45. generally on the first try.
  46. -- 
  47.  (This man's opinions are his own.)
  48.  From mole-end                Mark Terribile
  49.  
  50.  uunet!mole-end!mat, Somewhere in Matawan, NJ
  51.