Okay, I'm with you.  That jibes with my understanding of OOP in
a universal sense.  In ActionScript, however, classes *are* properties
of the _global object, which is what prompted my question.  Programmers
in general may agree to avoid global variables in principle, and what
I'm hearing is that ActionScript programmers, in a sense, pretend
_global isn't being used unless invoked explicitly.

Essentially, yes. The fact that classes are stored in _global is kind of like the red-headed bastard child we don't talk about. ;-) Macromedia used an ugly kluge to make it look kind of like a real namespace, so we look the other way and pretend it's not there until they fix it. Just because that's how they did it doesn't make it right, and it doesn't mean it should be part of good AS coding practices.

Global space has its place and can be very useful. But it can also be a debugging nightmare, and as such it is best to avoid it except in very simple cases. With an application object you can use getters and setters to track changes and raise events when things change, that way you know who set that global property and why, you can do validation on the values being set, etc. It's not an absolute no-no to use _global, but if you can save yourself some headaches in integration and debugging by going slightly out of your way not to use it, it's time well spent.

In my opinion, of course...

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