> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:flashcoders-
> [EMAIL PROTECTED] On Behalf Of Dennis Roche
> Sent: Tuesday, November 07, 2006 10:47 PM
> To: Flashcoders mailing list
> Subject: Re: [Flashcoders] Freelancer Class
> 
> I prefer the the double underscore naming scheme to differentiate a
> local/arugment variable from a class variable. It helps when you want
to
> create get/set functions and reminds you that it is a private variable
and
> should not accessed directly.
> 
> class Student
> {
>    private var __name:String;
>    public function Student(name:String)
>    {
>       __name = name;
>    }
> }

Me, too (well, single underscore), but we were talking about setting
properties, not variables. You might want to set a property in a field
because it has some kind of verification or formatting functionality.
For example:

class mypackage.MyClass {
        /**
         * Class constructor.
         *
         * @param       name    Name for this instance.
         * @see #name
         */
        public function MyClass(name:String) {
                this.name = name;
        }
        /**
         * An upper-case string which is the name for this instance.
         *
         * <p>Values are automatically converted to upper-case. May be
         * [EMAIL PROTECTED] null}.</p>
         */
        public function get name():String {
                return _name;
        }
        public function set name(value:String):Void {
                if (value instanceof String) {
                        _name = value.toUpperCase();
                } else {
                        _name = null;
                }
        }
        private var _name:String = null;
}


―
Mike Keesey


_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to