[mtasc] Getters and Setters
Allen, Christopher S.
CSALLEN at PARTNERS.ORG
Tue Nov 2 16:42:44 CET 2004
"using getters / setters is good practice"
This is true, however, you don't need to write getters and setters using the get
and set key words. You can just as easily use your own method names and produce
the same effect.
//For example you can write this:
private var _id:Number;
public function set id(id:Number) {
_id = id;
}
public function get id():Number {
return _id;
}
//like this:
private var _id:Number;
public function setID(id:Number) {
_id = id;
}
public function getID():Number {
return _id;
}
This is what I was referring to. I would recommend, as would most, that you
should never have public variables in your class and you should always use
accessor methods to manipulate all variables no matter what syntax you choose.
-Chris
-----Original Message-----
From: mtasc-bounces at lists.motion-twin.com
[mailto:mtasc-bounces at lists.motion-twin.com] On Behalf Of Brett Errington
Sent: Monday, November 01, 2004 9:40 PM
To: 'MotionTwin ActionScript2 Compiler List'
Subject: RE: [mtasc] Getters and Setters
Yeah, I'd have to agree
Using getters / setters is good practice (even though I know they have
issues in ActionScript as compared to other languages), plus I'm not going
to be able to use this compiler until they are supported as pretty much all
my AS2 code uses them and I'm not going to recode everything just to support
a different compiler.
Other than that, after giving the compiler some testing yesterday I'm really
enthusiastic about its future :) great work.
- Brett
-----Original Message-----
From: mtasc-bounces at lists.motion-twin.com
[mailto:mtasc-bounces at lists.motion-twin.com] On Behalf Of Lorenzo Sicilia
Sent: Thursday, 28 October 2004 12:19 AM
To: MotionTwin ActionScript2 Compiler List
Subject: Re: [mtasc] Getters and Setters
Allen, Christopher S. wrote:
> I'm pretty sure that there is a lot of existing code that is out there
that uses
> this style, and it would be a shame if people could not use this stuff
with your
> compiler. I would suggest that you allow this convention to keep MTASC as
> compatible as possible with the MMC.
You are rigth.
I think getter & setter is very importante because all best practice
about component use it and all my component use it :)
just my opinion.
regards Lorenzo
--
MTASC : no more coffee break while compiling
--
MTASC : no more coffee break while compiling
More information about the mtasc
mailing list