943,635 Members | Top Members by Rank

Ad:
Jul 8th, 2009
0

Coding Syntax

Expand Post »
Hey Everyone,
I know that AS3 uses what is called "camel coding", but it seems to that sometimes the names given to variables and especially functions could be shortened even more. Is "camel coding" a mandate or can they just be one word or just the first half. TO better illustrate my question may use "prev" as a function name instead of "prevPic" as long as prev is not a reserved word (which I don';t think it is)?

Thanks in advance.
Similar Threads
Reputation Points: 11
Solved Threads: 3
Junior Poster
Reliable is offline Offline
152 posts
since Jul 2007
Jul 10th, 2009
0

Re: Coding Syntax

Someone replied to you on
http://www.developphp.com/dev_forum/...tax%20question

In short, yes you can use prev instead of prevPic, but I say stick with prevPic since it's easier to know what the function might do. prev could mean many things. It's just better coding practice to stick with descriptive names.
Last edited by Phaelax; Jul 10th, 2009 at 11:50 am.
Reputation Points: 92
Solved Threads: 51
Practically a Posting Shark
Phaelax is offline Offline
856 posts
since Mar 2004
Jul 14th, 2009
0

Re: Coding Syntax

Sorry for adding to an already solved thread,
Generally the whoie camel case thing is just to make things more easily readable, but it's not at all mandatory as far as I'm aware.

You can make your variable names as long or short as you like (there may be an upper limit on the number of chars available for a variable name), the more descriptive they are, the easier it will be for others to understand your code.

I know in older versions of flash, having lots of variables with long names could cause a performance hit when running your final .swf, so shorter variable names were an advantage, but in AS3 I don't think it would make much difference as the AS3 engine is much faster and much more powerful!

With regard to styling code and camel case, most people start AS3 class names with capitals, and all other functions, properties and variables will be in camel case.
Some people insist on CAPITALISING the names of constant values, others insist on creating member variables with a leading underscore to differentiate between _classMembers and localVariables. Some people use camel case for classMemberVariables and functionNames and use all lowercase for local_variables, but at the end of the day it's down to you and how you find your code easier to read!

Most people tend to go with the CapitalsForClassNames and camelCaseForFunctions(), memberVariables and localVariables convention!
But as I said there's nothing stopping you from creating a class called myclass, or myClass...It might be frowned upon by others when you post your code on a forum, but flash won't complain!
Last edited by JasonHippy; Jul 14th, 2009 at 8:48 pm.
Reputation Points: 590
Solved Threads: 123
Practically a Master Poster
JasonHippy is offline Offline
672 posts
since Jan 2009
Jul 14th, 2009
0

Re: Coding Syntax

lol..cool...thanks for your input
Reputation Points: 11
Solved Threads: 3
Junior Poster
Reliable is offline Offline
152 posts
since Jul 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Graphics and Multimedia Forum Timeline: PLZ HELP..!!!!!!! A jpeg image having hyperlinks on the side pointing
Next Thread in Graphics and Multimedia Forum Timeline: Generate Random Number ?!?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC