Tim vs. Accessors

Michael Rueger michael at impara.de
Mon Oct 8 09:27:54 UTC 2007


tim Rowledge wrote:
> Ralph pretty much nailed my reasons for disliking the idea of always 
> making accessors methods for instvars. I can't vouch for the refactoring 
> browser though because I've never actually used it. Or even seen it so 
> far as I can remember...
> 
> What really upsets me is seeing code like this:-
> 
> thisPerson officeLocation office location x: otherPerson officeLocation 
> office location x + 12.

http://en.wikipedia.org/wiki/Law_of_Demeter

But then people never stick to design rules/laws/best practices, 
otherwise code like the above wouldn't be written in the first place.

Just stating "don't use accessors" will give people the idea that they 
can use instVarAt: instead. Trust me, I've seen this...

And for me using accessors even for local inst vars is enforcing 
ecapsulation, not the other way round.

Just MTC (Euro though ;-) )

Michael



More information about the Squeak-dev mailing list