I keep wondering about this to try to improve the performance and size of my Flex swfs, how do class methods and static methods or instances affect the performance and final size of the compiled "executable"? Thinking of how you could apply something like HAML and Sass to Flex ...
Let's say I create a very large admin interface with a lot of components and views, and each of these components has a Skin object to it (thinking about Spark Skinning Architecture for Flex ).
Now I want to add 10 different effects for each skin (let's say there are 100 components on the screen, so there are 1000 instances of the effects). Is it better:
- Each effect has a class (BlurEffect, GlowEffect ...) and add these 10 to the skin.
- All effects have instance methods in one larger class, say, “MultiEffect.as”, and add one class to the
multiEffect.glow() referenced as multiEffect.glow() . - All effects have static methods in the same Singleton-esque EffectManager.as class and simply reference effects on the skin through
EffectManager.glow(this) .
So,
- Several classes of effects for each skin, vs.
- One effect class for each skin with instance methods, vs.
- Class of one effect globally with static methods
How do these things affect memory and executable size (swf size in this example)? I know that classes are OO's best methods, and that static methods are slower than instance methods, and that singletones should be avoided, so this is not about performance. More on memory (in some cases, it would be a little better) and file size.
source share