Thread Solved

Join Date: Jul 2007
Posts: 84
Reputation: Reliable is an unknown quantity at this point 
Solved Threads: 2
Reliable Reliable is offline Offline
Junior Poster in Training

Coding Syntax

 
0
  #1
Jul 8th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 763
Reputation: Phaelax is on a distinguished road 
Solved Threads: 38
Phaelax Phaelax is offline Offline
Master Poster

Re: Coding Syntax

 
0
  #2
Jul 10th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 308
Reputation: JasonHippy is a jewel in the rough JasonHippy is a jewel in the rough JasonHippy is a jewel in the rough JasonHippy is a jewel in the rough 
Solved Threads: 52
JasonHippy's Avatar
JasonHippy JasonHippy is offline Offline
Posting Whiz

Re: Coding Syntax

 
0
  #3
Jul 14th, 2009
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.
There are 10 types of people in this world.....
Those who understand binary .....
And those who don't!
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 84
Reputation: Reliable is an unknown quantity at this point 
Solved Threads: 2
Reliable Reliable is offline Offline
Junior Poster in Training

Re: Coding Syntax

 
0
  #4
Jul 14th, 2009
lol..cool...thanks for your input
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC