[Newbies] Is it generally considered better practice for an object to access its own variables via its getter methods?

Andy Burnett andy.burnett at knowinnovation.com
Wed Aug 6 21:19:51 UTC 2008

> Andy> I noticed that the Seaside tutorial has code such as:
> Andy> html div class: 'menu';  with: self menuComponent.
> Andy> Whereas the Scriptaculous demo code does things like this:
> Andy> html paragraph id: 'position'; with: position.
> Andy> I.e. they didn't bother adding (or using) a getter for position.  Who
> is
> Andy> right, or doesn't it matter, or is there another reason why it would
> be
> Andy> written differently?
> Clearly, position is an instance var, or perhaps a temporary.  An instance
> var
> may or may not have accessors, depending on whether it is meant to be
> tweaked
> from the outside.  #menuComponent, on the other hand, may be just an
> accessor,
> or it may be a whole pile of code to generate that menu on the fly.  At
> this
> point, it doesn't matter.
> Whether internal accesses to instance vars should use accessors instead of
> direct access is a subject to debate (read: religious war).  I hope you
> haven't accidentally triggered that thread here.  I tend to do the simplest
> thing that works, and leave it at that.

Great, I am all in favour of pragmatism.  Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20080806/8ba938b6/attachment-0001.htm

More information about the Beginners mailing list