Tim vs. Accessors
Blake
blake at kingdomrpg.com
Sat Oct 6 05:30:25 UTC 2007
Hey, all,
If I may quote the esteemed Mr. Rowledge:
"Please, please, don't get in the habit of willy-nilly making accessors
for every instance variable. All you're doing that way is opening the door
to writing C code."
I believe the issue here is encapsulation, which I think we can
uncontroversially agree upon as a good thing.
However, I've always tried to take encapsulation as far as I can,
including using accessors as far as possible inside the object itself.
I've saved myself a fair bit of work over the years by doing so. (After
all, the benefits accrued by encapsulation to clients of an object are not
excluded from the object itself.)
To answer Tim's plea, I would point out that by default, I make said
accessors private. But of course, Smalltalk doesn't have a private
directive. Some would say, you can have private methods, you just have to
designate them as such, and others respect them (or not) at their own
peril.
I would submit, then, that accessors are no more or less opening-the-door
to C code than any other presumed private method.
Thoughts?
===Blake===
More information about the Squeak-dev
mailing list
|