home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / smalltal / 2808 < prev    next >
Encoding:
Internet Message Format  |  1993-01-24  |  1.4 KB

  1. Path: sparky!uunet!portal!cup.portal.com!ivang
  2. From: ivang@cup.portal.com (Ivan - Godard)
  3. Newsgroups: comp.lang.smalltalk
  4. Subject: Re: Voluntary method typing in ST80
  5. Message-ID: <74216@cup.portal.com>
  6. Date: Sat, 23 Jan 93 09:31:55 PST
  7. Organization: The Portal System (TM)
  8. References:  <9301191709.AA21420@bean.open.ac.uk>
  9. Lines: 33
  10.  
  11. >
  12. >>Can you give details/send code on your approach?
  13. >>
  14. >I got so fed up with defining 'record-like' objects with lots of setX,getX
  15. >type methods that I defined a Record as a subclass of Dictionary.
  16. >the only method is 'doesnotunderstand'.
  17. >If you send
  18. >obj setName: arg
  19. >
  20. >it bounces back as doesNotUnderstand.  this looks at the 'setName', peels
  21. >off the 'set' and sets name->arg in the dictionary.
  22. >similarly 'getName' retrieves it.
  23. >
  24. [...omission...]
  25. >
  26. >Of course, this only applies to database-type objects which just have
  27. >get/set behaviour, but this seems quite a significant subset.
  28. >
  29. >all the best,
  30. >>>benedict
  31.  
  32.  
  33. Faced with a similar problem, I defined a method Class>>accessMethods which
  34. ran through all the instance variables of a class and defined get and
  35. set methods for those instance names. Much simpler and much more
  36. performant. There is a reason for compilers, after all. If you do this,
  37. Make sure that the generated text contains comments indicating that it is
  38. mechanically generated, so that later you (or others) won't modifiy the
  39. method and then lose the modification when accessMethods is rerun.
  40.  
  41.  
  42.  
  43. Ivan
  44.