At 18:55 30.07.99 -0400, Chris Norton wrote:
I will admit to having used i-vars directly in the past. At the time, it seemed like a good way to ensure privacy, but upon reflection I decided that this was silly. Any developer can just add his/her own accessor. So now my practice is to create accessors, but label them as "private" and put them into "private" method categories. Since Smalltalk does not enforce privacy, we have to assume that our fellows will adhere to our "code of conduct".
</Soapbox>
<Déjà vu> I like the way Kent Beck reasons about it. In [SBPP] he lists *both* "Direct Variable Access" (p.89) and "Indirect Variable Access" (p.91) as valid coding patterns, alluding to the obvious schizophrenia, and mentioning encapsulation and dogmatism. ([SWS] is leaning towards indirect-only, IIRC.) In his recent [GTBS], featuring a reprint of his 1993 SmalltalkReport column "To Accessor or Not to Accessor", I found his leading remarks from today's view most interesting: "[...] It wasn't until I rewrote the while thing as patterns for the book [SBPP] that I realized the key issue here is communication." (The column itself stresses the importance of consistency in one's ways.) His conclusive remark: "Anyway, if this one bugs you, ignore it, all except the part about making accessors private by default."
These all make for good reading IMHO:
[SBPP] Beck, Kent: Smalltalk best practice patterns; Prentice-Hall 1997; ISBN 0-13-476904-X
[GTBS] Beck, Kent: Guide to Better Smalltalk; SIGS/Cambridge Univ. Press 1999; ISBN 0-521-64437-2
[SWS] Skublics, Suzanne; Klimas, Edward J.; Thomas, David A.: Smalltalk with Style; Prentice-Hall 1996; ISBN 0-13-165549-3
Back in a couple of days, Helge
squeak-dev@lists.squeakfoundation.org