Tim vs. Accessors

Blake blake at kingdomrpg.com
Sun Oct 7 07:47:18 UTC 2007


On Sat, 06 Oct 2007 19:57:47 -0700, Ron Teitelbaum <Ron at USMedRec.com>  
wrote:

> I know I shouldn't respond to this, I've spent enough time arguing this  
> in person to know that both sides have very valid arguments and strong
> opinions.  You know I just can't resist.

I didn't know I was enabling an addiciton.<s>

> I create accessors and mutators for all instance variables.

OK.

> I also create fake senders for performed methods with comments that  
> point developers to
> where the methods are performed.  Why?  Because everything you can do to
> help a developer understand what you did and why helps.

Oh! That seems like a good idea, although perhaps illustrates a  
shortcoming in the tools somewhere?

I have a strong aversion to "perform" and similar things. I've seen them  
predominately in dBase languages where they--they're just horrifying.

> Now I also try very hard to not use accessors and mutators outside the
> context of the object.  It doesn't always work out that way.  I almost
> always create instance creation methods.  I really do not support
>
> MyClass new foo: bar; yourself
>
> type creation from some other object.  I prefer
>
> MyClass class >> createForFoo: aBar ...
>
> I do this because it makes it much easier to trace a class and to figure  
> out how to use that class.

Ah! I do, too, but you can't do that unless the class object has access to  
the instance object's variables--or you put in accessors. (Well, that's  
not exactly true, of course, you can build an instance method which serves  
an essentially similar purpose to an accesor or set of accessors. But in a  
lot of cases, that seems very forced.)

> I know Tim said only create accessors and mutators for those ivars that
> should be exposed external to the object, but I disagree.  The benefits  
> to clarity and traceability outweigh the potential abuse.

I understand his point, too. It just strikes me that ST requires a degree  
of responsibility. (Though it might not hurt to allow a designation as  
"private", "protected" or what-have-you, that could show up in a  
Shout/etc. editor.)



More information about the Squeak-dev mailing list