Need feedback on simple idea

Oca Emilio eoca at afip.gov.ar
Fri Apr 11 13:25:33 UTC 2003


> -----Mensaje original-----
> De: Adam Spitz [mailto:aspitz at student.math.uwaterloo.ca]
> Asunto: Re: Need feedback on simple idea
> 
> Interesting. When do you use methods with the same names as instance
> variables? The only time I can think of is when I want to do some sort
> of lazy initialization thing, but then I think that the code
> communicates better if I call the variable something like
> "cachedWobulator" instead of just "wobulator".
Not juts that, many times I an no sure of what the final shape of an
object's internal structure will be, or what it's final responsibilities
will be and who will collaborate on that. The use of accessors as an 'a
priori' policy allows me to use encapsulation even within the object
protocol and defer decisions that I am not comfortable to take yet.

> I like the idea that an object is just something that responds to
> messages; it bothers me, at some weird aesthetic level, that accessing
> instance variables is different. 
Precisely, an object answers messages, but no exposes it's structure. That's
not good.

> At a more practical level, it bothers
> me that I should have to think about whether to use "accessor methods"
> or not. And at a completely superficial level, it really bugs 
> me to see the word "self" spewed all over my code. ;)
But if that method belongs to that object you could use accessors or not.
It's your choice.

Regards

	Emilio



More information about the Squeak-dev mailing list