I keep wondering about this to try to improve performance and size of my Flex swfs, how do classes vs. static methods vs. instance methods impact performance and the final compiled "executable's" size? Thinking how it might be possible to apply something like HAML and Sass to Flex...
Say I am building a very large admin interface with lots of components and views, and each of those components has a Skin object applied to them (thinking of the Spark Skinning Architecture for Flex).
Now I want to add 10 different Effects to every skin (say there are 100 components on the screen, so that's 1000 instantiated effects). Is it better to:
- Have each Effect be a Class (BlurEffect, GlowEffect...), and add those 10 to the skin.
- Have all Effects be instance methods in one larger class, say "MultiEffect.as", and add that one class to the skin, referenced like
multiEffect.glow()
. - Have all Effects be static methods in one singleton-esque "EffectManager.as" class, and just reference the effects in the skin via
EffectManager.glow(this)
.
So
- Multiple Effect Classes per skin, vs.
- One Effect class per skin, with instance methods, vs.
- One Effect class globally, with static methods
How do those things impact memory and executable size (swf size in this example)? I know that classes are better OO practices and that static methods are slower than instance methods, and that Singletons are to be avoided, so it's not about performance necessarily. More about memory (which if smaller would be better in some cases), and file size.