I noticed that the Seaside tutorial has code such as:
html div class: 'menu'; with: self menuComponent.
Whereas the Scriptaculous demo code does things like this:
html paragraph id: 'position'; with: position.
I.e. they didn't bother adding (or using) a getter for position. Who is right, or doesn't it matter, or is there another reason why it would be written differently?
cheers AB
"Andy" == Andy Burnett andy.burnett@knowinnovation.com writes:
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.
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.
Randal L. Schwartz wrote:
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.
There is a nice discussion of the pros and cons of each in:
http://stephane.ducasse.free.fr/FreeBooks/BestSmalltalkPractices/Draft-Small...
Pages 68-69.
My summary - direct for clarity, indirect for inheritance.
beginners@lists.squeakfoundation.org