I generally keep at least one singleton class which is responsible for storing global properties. I make those properties accessible with getters and setters so that I can allow changes in those properties to trigger events. You can't really do that if you use _global to store your data. Also, there is always a risk in name space collision if you load in other elements that also use global, where one or more variables use the same name and are thus inadvertently shared for different uses. You definitely do not want to use _global within any classes that you create, as that can cause entanglement, gives you no private protection, and does not properly contain your code into a well-defined unit with a well-defined API.

Nathan
http://www.nathanderksen.com


On Jan 31, 2006, at 6:26 AM, Manuel Saint-Victor wrote:

I'm reading about the wrongs of using _global in various books and articles
and blogs but I have used several extensions and resources that I am
confident are well built that seem to be making use of _global. My current
project has some use of _global in the code that I am updating an I m
wondering in which cases I should try to remove those.   Is there a
reference that I can read that would educate me on the reasons not to use _global and even tell me some workarounds that would allow me to safely use
_Global if it's necessary.  I'm familiar with the use of the Singleton
pattern but feel as if in some cases I might be better with some _globals.

One case in particular that I'm considering is for some functions that we would like to have globally available. Am I better off making them static
functions of a class (like  Math.random() etc)
and having people importing the class or just plopping them as functions on
the global timeline?

Thanks in advance-

Mani
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to