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

  1. Xref: sparky comp.object:2955 comp.lang.eiffel:974
  2. Newsgroups: comp.object,comp.lang.eiffel
  3. Path: sparky!uunet!tcsi.com!iat.holonet.net!uupsi!psinntp!bony1!richieb
  4. From: richieb@bony1.bony.com (Richard Bielak)
  5. Subject: Re: How to design a data structure library.
  6. Message-ID: <1992Jul21.124256.17256@bony1.bony.com>
  7. Organization: lost in NYC
  8. References: <1820@snap>
  9. Date: Tue, 21 Jul 92 12:42:56 GMT
  10. Lines: 174
  11.  
  12. In article <1820@snap> paj@uk.co.gec-mrc (Paul Johnson) writes:
  13.  
  14. [...]
  15.  
  16. >Cursors
  17. >-------
  18. >
  19. >The ISE library has the notion of a cursor within the object being
  20. >traversed.  Hence to traverse a list you put the cursor to the
  21. >beginning of the list and then at every step you move it forwards.
  22. >The code looks something like this:
  23. >
  24. >    from list.start; until list.offright loop
  25. >        list.item.foo;
  26. >        list.forth;
  27. >    end; -- loop
  28. >
  29. >In the Sig library, the cursors (called iterators) are separate from
  30. >the objects, so you have something like this:
  31. >
  32. >    from locn := list.iterator; until locn.finished loop
  33. >        list.item (locn).foo;
  34. >        locn.forth;
  35. >    end; -- loop
  36. >
  37. >The ISE system has the disadvantage that multiple iterations over a
  38. >list are difficult to do.  In particular, an interleaved iteration
  39. >involving two cursors at different points in the list can be very
  40. >tricky. 
  41.  
  42. I think that cursors should be separate from the data structure they
  43. are used to traverse. The main reason is to allow multiple iterations
  44. over the same list. The scheme present in the ISE library (with "mark"
  45. and "return") works OK within a single program. It fails, when the
  46. data structured is shared - either through a database or concurrent
  47. process.
  48.  
  49. With shared data structures the cursor can also specify the kind of
  50. lock (i.e. read or write) to take out on the elements being looked at.
  51.  
  52. >
  53. >RISC vs CISC
  54. >------------
  55. >
  56. >The ISE data structure classes have large numbers of features.  Many
  57. >of these provide efficient short cuts.  For instance there is a list
  58. >merge facility which removes items from one list and inserts them into
  59. >another.  The ISE linked list implementation allows this to be done
  60. >with a little internal pointer shuffling.  Other features are rarely
  61. >used and do not offer efficiency short-cuts.  For instance, the
  62. >`remove_all' procedure scans the list and removes all items which are
  63. >equal to the argument.  This could be done just as quicly by an
  64. >explicit loop.
  65. >
  66. >Inheriting from the ISE list classes can be a trial.  In order to
  67. >provide a true subtype, one has to implement a large number of
  68. >features, many of which are of doubtful utility and others for which
  69. >there are no clear semantics or implementation.
  70. >
  71. >The SIG design has none of this.  The data structure features provide
  72. >a bare minimum of functionality.  This makes the documentation simpler
  73. >to use, but some tasks are less efficient than they might be.
  74. >
  75.  
  76. I would prefer RISC. I think it was Jim McKim, who said that the
  77. features of a class should form a "minimum spanning" set - that is
  78. just enough to be complete, but not more.
  79.  
  80. I've implemented a persistent list class, which did _not_ inherit from
  81. LIST. The main reason was that LIST has too many things that I did not
  82. want to implement for persistent lists (eg. "mark", "return",
  83. "index_of", "duplicate).
  84.  
  85.  
  86. >
  87. >Functional vs Procedural
  88. >------------------------
  89.  
  90. [...]
  91. >
  92. >Things become worse when considering large objects.  The ISE SET class
  93. >provides `intersect', `merge' and `subtract' procedures.  Hence the
  94. >only way to create a new set `c' which is the union of two existing
  95. >sets `a' and `b' is:
  96. >
  97. >    c.Clone (a);
  98. >    c.merge (b);
  99. >
  100. >With some kinds of objects, this would be rather less efficient than
  101. >
  102. >    c := a + b;
  103. >
  104. >On the other hand providing operators `*' and `+' for intersection and
  105. >union would result in something like:
  106. >
  107. >    a := a + b;
  108. >
  109. >This creates a new (and fairly large) object before throwing away the
  110. >old value of `a'.  If this is implemented as a linked list then you
  111. >could have a huge amount of garbage being generated.
  112. >
  113. >Does it make sense to implement both kinds of operations in a class,
  114. >so that the programmer can pick the appropriate one?
  115. >
  116.  
  117.  
  118. I suppose one should implement only the more fundamental set of
  119. operations, and then let the descendant create the "+" or "*"
  120. operators if desired. This goes back to the "minimal spanning set"
  121. idea.
  122.  
  123.  
  124.  
  125. >Documentation
  126. >-------------
  127. >
  128. >What should go into the documentation of a cluster?
  129.  
  130. Good question. There should be a general description of what the
  131. classes are doing. For example, the description of data structure
  132. cluster should talks about cursors.
  133.  
  134. >What should be in the documentation of each individual class?
  135.  
  136. At least "flat class | short" :-)
  137.  
  138. >Do we need discussion of time and space complexity?  At what level of
  139. >detail?
  140.  
  141. I think so. Sometimes a simple guideline on how to use a class
  142. efficiently would suffice.
  143.  
  144. >Do we also need an outline of the implementation method?  At what
  145. >level of detail?
  146.  
  147. This is probably not needed, as long as the source code is available.
  148.  
  149.  
  150. >Is the short-flat version of a class useful? (Sig appear to think
  151. >not).
  152.  
  153. It's essential.
  154.  
  155. >Do we need a separate section: "Guide to Writing Descendants"?
  156.  
  157. I think so. I'm in process of writing docs for a database cluster, and
  158. large part of the doc will be on that topic.
  159.  
  160. What would be useful is a "short-for-descendants". An extract of a
  161. class that contains the signatures of all the features, without the
  162. code.
  163.  
  164. >What sort of examples are needed?
  165.  
  166. At least an example of typical use. Perhaps some examples that
  167. illustrate the difference between efficient and inefficient use of the
  168. library.
  169.  
  170.  
  171. >Are inheritance graphs useful?
  172. >
  173.  
  174. I don't find these particularly useful, although they are pretty to
  175. look at.
  176.  
  177.  
  178.  
  179. ...richie
  180.  
  181. -- 
  182. * Richie Bielak   (212)-815-3072   | "Your brain is a liquid-cooled parallel  *
  183. * Internet:       richieb@bony.com | super-computer". He pointed to his nose, *
  184. * Bang {uupsi,uunet}!bony1!richieb | "This is the fan."                       *
  185. *    - Strictly my opinions -      |                     - David Chudnovsky - *
  186.