Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!pacbell.com!pacbell!m5!tma From: tma@m5.COM (Tim Atkins) Newsgroups: comp.lang.smalltalk Subject: Re: Access methods - New feature ? Message-ID: <4753@m5.COM> Date: 24 Apr 91 21:59:17 GMT References: <1991Apr21.221149.8057@vuse.vanderbilt.edu> Reply-To: tma@m5.UUCP (Tim Atkins) Organization: Object Sciences Corp., Menlo Park, CA Lines: 32 Seems to be a lot of hype around this question so I'll post my own. One point that has been neglected somewhat is that well designed classes tend to have named instance variables that clearly encapsulate data-ish parts of the problem domain. Sending a message to get at this held data via a request to its encapsulator is perfectly ok. If the encapsulator did not want to allow access (read only here) to this data that class would not have done so. From an external point of view it is not knowable whether a particular method just returns the value of an instance variable or computes its result. This is encapsulation! To me it has nothing whatsoever to do with what in fact is the implementation of the method. Also it would be silly to make up some new name for the method that was not the instance variable name. I believe most posters grant this. There is a valid point that over-reliance on such data-ish features often fails to produce a good design. But this is more a design viewpoint issue than an implementation guideline. It is all too easy to view the world as a bunch of data structures like we learned back in the dark ages instead of as a set of "objects" capable of responding to methods. For this reason I tend to get a bit frustrated with OOD and OOA tools that concentrate early on data relationships in the design. Another point that has not been made is that good OO programming style asserts that instance variables should always be accessed indirectly through methods, even by methods of the same class and its subclasses. One reason is that any other approach makes the system very fragile and hard to modify. Given that this is so, it makes a great deal of sense to have automatically generated access methods available. - Tim Atkins