[Newbies] Accessors for everything?
david.mitchell at gmail.com
Tue Jan 6 14:38:23 UTC 2009
I've seen both.
I try to avoid creating accessors and only add them as I need. I try to
create methods based on the responsibilities of the object and not around
its data structure.
But, I've worked on projects where every object had accessors for every
variable (often necessitated by the persistence framework). You have to
trust the programmers not to abuse them as a simple data structure.
Kent Beck's Smalltalk Best Practice Patterns describes the forces behind
Another reason to use accessors is lazy initialization.
On Tue, Jan 6, 2009 at 8:17 AM, Ryan Zerby <tahognome at gmail.com> wrote:
> I'm going through the laser game example presented on this list a
> short time ago. I notice that he creates accessors for everything.
> Can someone explain the reasoning for that? I can understand having a
> wrapper for those functions for which you want external access.
> However, doesn't it effectively remove the protection of private
> variables by providing such open access on EVERYTHING.
> What's the Tao of Squeak on this subject?
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners