- Joined
- Dec 14, 2005
- Messages
- 10,532
Alright, we need to be careful to be consistent in terms of coding conventions so as to not confuse the users or send them mixed messages. So here we go (input is welcome):
local and global variables are named in lowerCamelCase
constants are named in ALLCAPS
functions are named in UpperCamelCase
prefixes and suffixes are appended with underscores.
--
Stuff below here is not generally followed by experienced JASSers, but will be helpful to newbies.
Variable names should be descriptive even if it results in them being long. They should also use everyday words unless the relevant term has already been introduced.
For example,
Using "iterator" instead of counter would be a no-go until the point in the course where we describe what iteration actually is.
--
Globals should be prefixed with "global" to separate them from locals.
--
Be very careful not to use concepts (like constants) until they have been introduced, even if your code is worse from a practical standpoint because of their lack of inclusion.
local and global variables are named in lowerCamelCase
constants are named in ALLCAPS
functions are named in UpperCamelCase
prefixes and suffixes are appended with underscores.
--
Stuff below here is not generally followed by experienced JASSers, but will be helpful to newbies.
Variable names should be descriptive even if it results in them being long. They should also use everyday words unless the relevant term has already been introduced.
For example,
JASS:
function DisplayOneToTen takes nothing returns nothing
local integer counter = 1
loop
exitwhen counter > 10
call BJDebugMsg(I2S(counter))
set counter = counter + 1
endloop
endfunction
Using "iterator" instead of counter would be a no-go until the point in the course where we describe what iteration actually is.
--
Globals should be prefixed with "global" to separate them from locals.
JASS:
globals
integer global_myInteger //Note that prefixes/suffixes do not confirm to CamelCase restrictions
real global_myReal
endglobals
--
Be very careful not to use concepts (like constants) until they have been introduced, even if your code is worse from a practical standpoint because of their lack of inclusion.