General question on using Singleton classes in an AS3 application: If I have a data model that is pretty complex, and have lots of different view classes that have a reference to the model instance, does performance get sacrificed?
In other words, I want all my view components to extend a base class that has a reference to the model. Will that affect the performance of my app? Or is it okay because they’re just pointers referencing a singleton instance?
I don’t think it’s a good idea to let all your views have access to the model, just because you may need it.
Other than that, I see no problem. The views will simply hold a reference to some object, which comes at a cost of 4 Byte per reference, which is basically negligible in comparison to all the memory views actually need.
Technically, accessing fields is faster than accessing global objects (class objects are global objects for example), but in this case I also doubt this will matter.