home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / object / 4633 < prev    next >
Encoding:
Text File  |  1992-12-22  |  4.6 KB  |  94 lines

  1. Newsgroups: comp.object
  2. Path: sparky!uunet!elroy.jpl.nasa.gov!swrinde!gatech!destroyer!cs.ubc.ca!unixg.ubc.ca!kakwa.ucs.ualberta.ca!acs.ucalgary.ca!jabraham
  3. From: jabraham@acs.ucalgary.ca (John Abraham)
  4. Subject: Re: Object Relations - was: Re: Object hidden s
  5. Sender: news@acs.ucalgary.ca (USENET News System)
  6. Message-ID: <92Dec22.170044.16343@acs.ucalgary.ca>
  7. Date: Tue, 22 Dec 92 17:00:44 GMT
  8. References: <92Dec16.182308.20249@acs.ucalgary.ca> <1992Dec17.143742.16507@fripp.ri.cadre.com>
  9. Nntp-Posting-Host: acs6.acs.ucalgary.ca
  10. Organization: The University of Calgary, Alberta
  11. Lines: 81
  12.  
  13. In article <1992Dec17.143742.16507@fripp.ri.cadre.com> jc@ri.cadre.com writes:
  14. >
  15. >I've encountered this problem, too.  It comes home to roost for me
  16. >as life-time control.  Who "owns" or implements those secondary
  17. >relationships?  In really nitty-gritty terms, where (in what scope)
  18. >do you put the collections (sets. lists, whatever) that implement
  19. >the relationship?
  20. >
  21. >An approach that seems to have some promise starts with structuring
  22. >the design/implementation around the aggregation hierarchy of the
  23. >problem.  The aggregation instances (e.g., "car" in your post), own
  24. >(control the lifetimes) of the constituent instances.
  25. >
  26. >Next, the secondary relationships can be implemented in (placed in
  27. >the scope of) the lowest common aggregator in the aggregation
  28. >hierarchy that controls the lifetimes of the objects that the
  29. >secondary relationship relates.
  30.  
  31. This is probably where these secondary relationships should be
  32. controlled - in the lowest common aggregator.  But sometimes, for
  33. efficiency reasons, I don't do that.  Instead of having the
  34. "transportation system" control the relationship between the (car
  35. with wheels) and the road, I have the wheels containing a pointer
  36. to the surface that they are on.  This can cause maintenance and
  37. debugging nightmares, but it seems to be necessary on occasion.
  38. Usually, however, the wheels (or the car) will query the
  39. "transportation system" to determine what surface they are on, so
  40. I suppose, ultimately, the relationship *is* controlled by the
  41. lowest common aggregator, but I end up with redundant
  42. information since the wheel also contains a copy of the
  43. relationship.  This causes problems if the lifetime of the
  44. relationship is terminated by the "transportation system" and
  45. no-one bothers to tell the wheel about it.
  46. >
  47. >This may require that a top-level or "super-aggregator" class be
  48. >introduced to provide a global scope to implement relationships
  49. >like "rubber-meets-road" in your example.  You might have to have a
  50. >Transportation-system class which is at a sufficiently high
  51. >abstraction to "contain" the relationship.
  52. >
  53. Things I don't like about this solution (although it's the
  54. only one I've got so far):
  55. 1) the "super-aggregator" can end
  56. up containing virtual all of the secondary relationships in the
  57. application.
  58. 2) it cuts down on re-use possibilities - no one
  59. else would be able to re-use my car object without creating their
  60. own object that can tell my car what surface its wheels are on.
  61.  
  62. >As an example, we might have an aggregation hierarchy in which a
  63. >TransportationSystem has terminals, and trucks.  Terminals have
  64. >employees, routes, and customers.  "Have", in this context, denotes
  65. >aggregation.  So, for instance, the "terminal has routes"
  66. >relationship would be implemented in the Terminal objects.  A
  67. >secondary relationship like "truck is used by employee on route"
  68. >has as its objects, route and employee, both owned by Terminal, and
  69. >truck, owned by TransportationSystem.  So, the lowest common
  70. >aggregator is TransportationSystem.
  71. Good example.  The employee-truck-route relationships are
  72. controlled by the tran.sys.  But surely the truck also needs to
  73. know who's driving it, without asking the tran.sys.  So the
  74. truck, employee and route are all owned by the tran.sys., and the
  75. tran.sys controls (owns) the relationships between them, but
  76. these relationships are, at least temporarily, independant of the
  77. tran.sys.  While the driver is trucking down the road drinking
  78. coffee his relationship with his truck is almost completely
  79. independent of his relationship with his employer.
  80.  
  81. >
  82. >Note that in all of this, inheritance is not a concern.  In fact,
  83. >worrying about inheritance at an early stage of design can cause a
  84. >lot of problems.
  85. AGREED.  Coad-Yourdan recommend not worrying about inheritance
  86. until final design-implementation.
  87.  
  88. -- 
  89. John E. Abraham                       ***** University of Calgary
  90. jabraham@acs.ucalgary.ca               **** Department of Civil Engineering
  91. Mathematical Modelling                  *** 2500 University Dr. N.W.
  92. Computer Simulation                      ** Calgary, AB, T2N 1N4
  93. Transportation and Land Use Interaction   * Canada
  94.