Thanks again for the answers. The only thing i am a bit bothered about
is the following paragraph i am reading.
"Instance variables can be accessed by name in any of the instance methods
of the class that defines them, and also in the methods defined in its
subclasses.
This means that Smalltalk in
There are two subjects here. Let me start with Oscar's query first.
Since protocols in Smalltalk are a suggestion but not enforceable, I
tend to avoid (ii) as much as possible and use instance variable
methods with lazy initialization as much as possible to have short
initialize methods.
As said, it is a matter of style.
I rather use accessor methods (private mostly) because of lazy initialization.
If you don't use lazy initialization, and always have valid objects in
the instance variables, then you can use direct variable access or
simply a message send.
I also choose message s
Yes. "Kind of" is the right term. In Smalltalk, an object cannot
access variables of another instance of the same class. Whereas in
Java this is allowed.
Cheers,
Alexandre
On 21 Oct 2009, at 09:59, Gerben van de Wiel wrote:
> Thank you very much, if i understand it correctly then instance va
Yes. They key difference is that the abstraction boundary is the
object, not the class.
In Java, another instance of the same class can access your "private"
instance variables.
In Smalltalk, it cannot (unless reflection is used).
- on
On Oct 21, 2009, at 14:59, Gerben van de Wiel wrote:
Thank you very much, if i understand it correctly then instance vars
in SmallTalk are "kind of" protected members in languages like Java
and C#?
Regards,
Gerben
___
Pharo-project mailing list
Pharo-project@lists.gforge.inria.fr
http://lists.gforge.inria
As Oscar said, it's an style question.
I prefer to reference directly the instance variable in this context and
don't expose private state, and also prefer to put the instance variables
definition in the concrete classes and not in the abstract ones.
Regards,
Gabriel
On Wed, Oct 21, 2009 at 6:45
Hi Gerben,
It is really a question of style. Some people promote the use of
accessors aggressively for all instance variable access. The down
sides are (i) proliferation of accessor methods, and (ii) exposure of
private state to other objects. If you do decide to use accessors,
you sho
Hi,
I am very new to Pharo and Smalltalk in general. When reading through
the excellent PBE book i was wondering about something on page 32.
In that piece of code the LOCell class is using some instance
variables from it's super classes, and i was wondering if it isn't
best practice to use
message