home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!portal!cup.portal.com!ivang
- From: ivang@cup.portal.com (Ivan - Godard)
- Newsgroups: comp.lang.smalltalk
- Subject: Re: Voluntary method typing in ST80
- Message-ID: <74216@cup.portal.com>
- Date: Sat, 23 Jan 93 09:31:55 PST
- Organization: The Portal System (TM)
- References: <9301191709.AA21420@bean.open.ac.uk>
- Lines: 33
-
- >
- >>Can you give details/send code on your approach?
- >>
- >I got so fed up with defining 'record-like' objects with lots of setX,getX
- >type methods that I defined a Record as a subclass of Dictionary.
- >the only method is 'doesnotunderstand'.
- >If you send
- >obj setName: arg
- >
- >it bounces back as doesNotUnderstand. this looks at the 'setName', peels
- >off the 'set' and sets name->arg in the dictionary.
- >similarly 'getName' retrieves it.
- >
- [...omission...]
- >
- >Of course, this only applies to database-type objects which just have
- >get/set behaviour, but this seems quite a significant subset.
- >
- >all the best,
- >>>benedict
-
-
- Faced with a similar problem, I defined a method Class>>accessMethods which
- ran through all the instance variables of a class and defined get and
- set methods for those instance names. Much simpler and much more
- performant. There is a reason for compilers, after all. If you do this,
- Make sure that the generated text contains comments indicating that it is
- mechanically generated, so that later you (or others) won't modifiy the
- method and then lose the modification when accessMethods is rerun.
-
-
-
- Ivan
-