> I'm wondering what the caveats are of using getters this way.
 
My only caveat would be that we consider it best practice for getters to
be lightweight. If you do a lot of computation in a getter, other people
using your getter may not realize that it is slow, and they might call
it too frequently, say in a loop. People's expectation is that
properties are fast while methods are slower. So if we have a
heavyweight method that computes something at returns it, we make it a
method instead.
 
- Gordon

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of bithroop
Sent: Friday, August 24, 2007 3:28 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Getter and Setter Ramifications...



I have been using getters and setters in places where I don't
necessarily have a private member variable that I'm affecting, but
instead am doing one of the following:

- using a getter to run a function that collects implicit data. Like
for instance, I might step through a list and return all members that
have a field set to TRUE. So instead of keeping a private var of this,
I just return the result.

- using a getter to do the same but just so I can see what the
contents are in the debugger.

I'm wondering what the caveats are of using getters this way. Anyone?



 

Reply via email to