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

  1. Newsgroups: comp.object
  2. Path: sparky!uunet!rational.com!thor!rmartin
  3. From: rmartin@thor.Rational.COM (Bob Martin)
  4. Subject: Re: Booch question: new class relationship?
  5. Message-ID: <rmartin.728269221@thor>
  6. Sender: news@rational.com
  7. Organization: Rational
  8. References: <894@ulogic.UUCP> <rmartin.727740331@thor> <1993Jan28.204928.10352@rational.com>
  9. Date: Fri, 29 Jan 1993 01:00:21 GMT
  10. Lines: 47
  11.  
  12. paul@melody.Rational.com (Paul Jasper) writes:
  13.  
  14. |In article <rmartin.727740331@thor>, rmartin@Rational.COM (Bob Martin) writes:
  15.  
  16. |> Containment by value represents the notion that the storage of the
  17. |> contained class exists within the storage of the containing class.
  18. |> The containing class has intrinsic knowledge of the contained class
  19. |> (ie. knows where to find it).  The contained class is created and
  20. |> destroyed with the containing class.  
  21.  
  22. |Yes, this is correct, but then you add:
  23.  
  24. |> The contained class cannot be polymorphic.
  25.  
  26. |Tut, tut, Bob!  You should know this ;^)
  27.  
  28. |"Has by value" doesn't necessarily imply physical containment.  The
  29. |"intrinsic knowledge" may still be a pointer or even a database reference,
  30. |but the semantics will still be that instances of the sub-class are 
  31. |created and destroyed with the parent object.  
  32.  
  33. Ah! I think we are confusing containment by value with "Ownership".  A
  34. class "owns" the object it contains if, upon its own death, it kills
  35. the contained object.  This, however, IMHO is not containment by
  36. value.  Containment by value is when the storage for the contained
  37. is within the storage for the containing.  Certainly the
  38. containing class then "Owns" the contained class, since the contained
  39. object will die with the containing object.  But is also means that
  40. the absolute type of the contained object is known, and so cannot be
  41. polymorphic.
  42.  
  43. Containment by reference, on the other hand, can be polymorphic
  44. becuase it implies that the contining objects simply contains a
  45. pointer or a reference to the contained object.  It is containment in
  46. that the containing object has intrinsic knowledge of the contained
  47. object.  But it does not imply ownership since there is no guarantee
  48. that the containing object will destroy the contained object when it
  49. dies.
  50.  
  51. To my knowldege, there is no notation for ownership in the Booch
  52. notation.
  53.  
  54. --
  55. Robert Martin       | Design Consulting    | Training courses offered:
  56. R. C. M. Consulting | rmartin@rational.com |  Object Oriented Analysis
  57. 2080 Cranbrook Rd.  | Tel: (708) 918-1004  |  Object Oriented Design
  58. Green Oaks, Il 60048| Fax: (708) 918-1023  |  C++
  59.