home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / object / 5098 < prev    next >
Encoding:
Text File  |  1993-01-28  |  2.3 KB  |  71 lines

  1. Newsgroups: comp.object
  2. Path: sparky!uunet!rational.com!melody!paul
  3. From: paul@melody.Rational.com (Paul Jasper)
  4. Subject: Re: Booch question: new class relationship?
  5. Message-ID: <1993Jan28.204928.10352@rational.com>
  6. Sender: paul@melody (Paul Jasper)
  7. Reply-To: paul@rational.com
  8. Organization: Rational
  9. References: <894@ulogic.UUCP> <rmartin.727740331@thor>
  10. Date: Thu, 28 Jan 1993 20:49:28 GMT
  11. Lines: 58
  12.  
  13. In article <rmartin.727740331@thor>, rmartin@Rational.COM (Bob Martin) writes:
  14. > hartman@ulogic.UUCP (Richard M. Hartman) writes:
  15. > You can mail a letter to prod_info@rational.com asking them for
  16. > Booch's latest paper on the notation.  In that paper you will find
  17. > what you are looking for. 
  18.  
  19. This is now available by e-mail in PostScript form, from the same address
  20. (or phone 1-800-ROSE-237).
  21.  
  22. > Containment by value represents the notion that the storage of the
  23. > contained class exists within the storage of the containing class.
  24. > The containing class has intrinsic knowledge of the contained class
  25. > (ie. knows where to find it).  The contained class is created and
  26. > destroyed with the containing class.  
  27.  
  28. Yes, this is correct, but then you add:
  29.  
  30. > The contained class cannot be polymorphic.
  31.  
  32. Tut, tut, Bob!  You should know this ;^)
  33.  
  34. "Has by value" doesn't necessarily imply physical containment.  The
  35. "intrinsic knowledge" may still be a pointer or even a database reference,
  36. but the semantics will still be that instances of the sub-class are 
  37. created and destroyed with the parent object.  
  38.  
  39. Hence, polymorphism is perfectly acceptable.  In fact, it is used quite
  40. frequently.  For example, in designing a tree, you might have an abstract
  41. base class representing a node.  The child nodes can be represented by a
  42. circular "has by value" relationship back to itself (er, "reflexive"?).
  43. Obviously, this can't be implemented by physical containment.  Concrete
  44. sub-classes inheriting from the node class can then be defined for each 
  45. of the types of data to be stored in the tree, for example, to allow
  46. mixed trees of strings, integers and reals with polymorphic behavior.
  47.  
  48. >     class ContainingByValue
  49. >     {
  50. >       Contained x;
  51.           // or Contained *x;
  52. >     };
  53.  
  54. class ContainingByValue
  55. {
  56.     ContainingByValue **children;
  57. };
  58.  
  59. class ContainingByValueString: ContainingByValue
  60. {
  61.     char *data;
  62. };
  63.  
  64. -- 
  65. -- Paul Jasper
  66. -- RATIONAL
  67. -- Object-Oriented Products
  68. --
  69.