- Original Message -
From: Matthias Dittgen [EMAIL PROTECTED]
To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com
Sent: Wednesday, February 14, 2007 8:54 AM
Subject: Re: [Flashcoders] Coding Standards: Use of Get/Set
You always compare implicit getter/settter with explicit getter
Just to fuel your query, how does it affect the user to know whether
they are 'get'-ing from a variable or a function call, encapsulation
considered?
P.
-Original Message-
From: [EMAIL PROTECTED] [mailto:flashcoders-
[EMAIL PROTECTED] On Behalf Of Holth, Daniel C.
Sent: Tuesday,
The biggest complaint that I have seen is the issue of speed. If you do
var foo: String = obj.theLetterA you expect that to be a hash
lookup/dereference/something fast. If you do var foo: String =
obj.getSomething() and you are thinking about speed, you go and look at
what getSomething() is doing.
On 2/13/07, Holth, Daniel C. [EMAIL PROTECTED] wrote:
I was wondering what people's thoughts were on the use of get and
set functions. I personally have felt that creating functions such
as:
public function get theLetterA(){
return a;
}
so the user can simply call
Get/set is useful when creating a visual object class, as well as for
setting private variables on set. It's also useful when you don't want
the variable that is being set to be getted, as well.
For instance, I have an application which allows a user to type in the
day, month and year into three
Just thought of another use for properties: component parameters.
With properties you can do something like this:
[Inspectable]
public function get percent():Number {
return _percent;
}
public function set percent(value:Number):Void {
_percent = normalizePercentage(value);
}
private var
I use implicit getter/setters all the time when it involves a single property
of an object:
width, height, visible, etc..
I use explicit getter/setters when one or more parameters are required:
getItemAt(index), setSize(w, h)
Implict getter/setters are also invoked before the constructor, which
One of the few reasons to use explicit getters/setters in AS2 is as
part of an interface. AS2 does not allow implicit property getters and
setters in interfaces.
// Will not work in AS2:
interface Ratio {
function get percent():Number;
}
// Will work in AS2:
interface Ratio {
function
You always compare implicit getter/settter with explicit getter/setter.
Just a thought of mine is to compare implicit getter/setter with
public variables.
When you use someClass, that was written by someone else, you do not
know if the following code uses implicit getter/setter or is just a
9 matches
Mail list logo