home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / object / 3197 < prev    next >
Encoding:
Internet Message Format  |  1992-08-13  |  3.8 KB

  1. Path: sparky!uunet!psinntp!internet!sbi!zeuswtc!pascal!rhsu
  2. From: rhsu@pascal.sbi.com (Robert Hsu)
  3. Newsgroups: comp.object
  4. Subject: Re: Class methods (was: Re: How to design a data structure library)
  5. Message-ID: <1308@pascal.sbi.com>
  6. Date: 13 Aug 92 00:58:37 GMT
  7. References: <GEOFF.92Jul27100601@wodehouse.flash.bellcore.com> <1992Aug10.232507.13304@projtech.com>
  8. Organization: Salomon Brothers Inc. NYC
  9. Lines: 63
  10.  
  11. steve@projtech.com (Steve Mellor) writes:
  12. > There seem to be two issues here:
  13. >     (1)  Can a function be an object?
  14. >     (2)  Is it OK to suppress detail at the analysis level?
  15. > I would argue that there is an associative object, call it Copulation,
  16. > between Man and Woman.  This object has data, has a lifecycle with
  17. > events, transitions and actions, and finally, it has functions that 
  18. > drive the object through its lifecycle.  This is an object like any other.
  19.  
  20.     You are therefore answering yes to your first question.  This
  21. very issue is being discussed in another thread currently, and I think
  22. it appropriate that, talking about this "associative" object you
  23. mentioned, we should expand the breadth of our discussion and inject
  24. some (hopefully penetrating) insight into it.
  25.  
  26.     Can a function be an object?  By one criterion, an object
  27. should have state information, and any action that is "durationless"
  28. should be a simple function.  Most certainly, our object is not
  29. durationless (if it were, the world would be a very boring place).
  30. But perhaps by "durationless" what is meant is that the action occurs
  31. as a single step, and that each individual invocation of it is
  32. independent of any other.  Is this the case with our object?  At first
  33. sight, yes, which seems to suggest that it should be a function and
  34. not an object.  But on the other hand, does it retain state
  35. information?  My opinion is that it does, and therefore should be an
  36. object.  For example, this object imposes restrictions on when it can
  37. occur (for such reasons as the phase of the moon, the direction of the
  38. wind, the time of day, whether one is in Virginia, etc.).  This is
  39. state information that should be kept in the object.
  40.  
  41.     Obviously, one can make a function an object.  The real
  42. question is: should a function be an object?  Using the previous
  43. example, some people see it as a function, noting that the elegance of
  44. such a straightforward act is ruined when it is enveloped by an
  45. unnatural barrier - the class protocol.  Others consider it not only
  46. more elegant to have that protocol, but also much safer, since it
  47. provides more protection, and they are therefore willing to accept any
  48. inconveniences. 
  49.     
  50.     My own opinion is that in general, functions should not exist
  51. independent of a class (i.e. avoid global functions).  In practice
  52. this seldom requires constructing artificial classes just to encompass
  53. all functions, because most functions do not exist independent of
  54. either their parameters or other related functions.  The first place
  55. to look for de-globalizing a stray function is to see if it can go
  56. into the class of any of its arguments.  If that doesn't work, the
  57. next step is to look for a group of related functions that have some
  58. attributes in common, and make a class for all of them.  Only when
  59. this doesn't work are you required to make an artificial class for
  60. just one function - but this should be done nevertheless, because even
  61. this one function will probably have some global state information
  62. associated with it.  What you gain from this is 100% classification (a
  63. pun? or an eerily profound illustration of the meaning of "class"), so
  64. that nothing exists outside of a conceptual abstraction.  This usually
  65. also brings a soothing feeling of aesthetic achievement.
  66.  
  67. -Robert
  68.  
  69. -- 
  70.     // Robert Hsu -- Salomon Brothers Inc. -- rhsu@aristotle.sbi.com \\
  71.     \\   DISCLAIMER: Opinions expressed are not necessarily mine     //
  72.