On 6/1/07, Steven Sacks <[EMAIL PROTECTED]> wrote:
> And since we're talking best practices, you don't
 > have any public instance variables anyhow, hmm? :)

I don't know what "best practice" you're referring to that claims that
you shouldn't have public instance variables.

Grin. Well, he said OO best practices, not ActionScript ;)

Traditional OO design rules state that you should always encapsulate
your instance data in getters and setters. The general idea being that
external classes should never have the ability or need to manipulate
your data for you - they should have to ask nicely and then accept
whatever you're willing to do in stead. And I agree with that for the
most part.

While I can understand the use of public instance variables in AS2 and
AS3 them because of backwards mental compatibility with AS1... I only
use them in AS2 when the project already does - which is often since
most of the AS2 I work with was written by former AS1 devs ;) It's
also kind of unreasonable to expect people to use private properties
in such a weakly typed language anyway.

I find this regrettable in AS2 but acceptable in AS3 since you can
still just hook into the property and listen for changes and respond
accordingly. That gives you the control you need to safeguard your
internal data.

Ammon
_______________________________________________
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