Muzak wrote: [fixed top posting]
No need to get hyper about "this".
The matter stays that "this" used to be essential in AS1, thus probably why
people still like to implicate him in their code. But I agree that putting
"this" in an AS2 Class should be used only when necessary.
>
> You do know that it (this.) is being added for you at compile time in AS2, right?

Who cares? All that means is that there is no semantic difference between the two. Given that fact, you should use whichever syntax makes your own life easier as a programmer and is more maintainable. I started off using "this." a lot, partly because in Director there really *is* a semantic difference between explicitly using "me" (the equivalent of "this") or not - leaving it out is faster but can cause maintenance problems. You therefore get into the habit of always explicitly using "me." and I initially carried this practise across to AS2.

However as I tend to write a lot of static utility classes, I had to get out of the habit fairly quickly. I also found that I quite often wanted to take a bit of code from one class and put it into another class, which doesn't work if one is static and the other has "this." all over the place. After getting really sick of rewriting code all the time, I just dropped "this." entirely. My code does look cleaner that way, so I'm not going back.

If you really, really want to distinguish member properties from local variables, use prefixes. Or better yet, just write your code clearly (with comments if necessary) so that there isn't any ambiguity over what each variable is supposed to be for. There really is no good reason to include explicit "this" references everywhere.

- Robert
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to