[EMAIL PROTECTED] wrote: > this should be kind of a simple one. I have been creating my Private > variables as simple camelCased names. > > private var variableName:VariableType; > > I have seen other people creating them as underscore camelCased names and > recently I was challenged that the underscore was the correct and best > practice. > > private var _variableName:VariableType; > > I'm not convinced. Does any one have any definative information or > experience of this from an OO best practices perspective and an > explanation of why the right answer is right?
When it comes to "best" practices, the best thing you can do is be consistent. Whether that means consistent with your other library of work or consistent with the rest of the code in a project you have joined, making your code as reliably similar to other associated code should probably be your highest priority. Thus, if you are editing a class that uses underscores for instance variables, you should too. If they don't, then you probably shouldn't either - it gets confusing fast. Personally, I do lean toward using underscores for my instance variables if I can get away with it. This allows for a clean distinction between instance and local variables and is a very easy habit to get into. It's certainly a whole lot nicer and easier to parse visually than having bunches of myThis and myThat ;) It is especially handy to use underscores when you are writing getters and setters for those variables to further distinguish them - you don't have to pick a different name for your public property. And since we're talking best practices, you don't have any public instance variables anyhow, hmm? :) Some people will use two underscores for private vars and one for protected or will come up with some other way to use more underscores. I would recommend against mixing and matching - that degrades readability and gets confusing. You should use either one or two... and two doesn't really gain you anything. I don't know when the last time I used two underscores before a variable name was. Probably in another language when I'm not camel casing things, private instance vars might be named __core_temperature, or something like that. But it's been a while, and since the AS convention is camel casing... consistency above all else ;) Ammon _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com