Here
are some of my opinions on naming conventions. I try to follow
the most used conventions and formats.
When
naming objects, variables, scripts, and resources; try your hardest
to give them names that mean something to you. If the names of
things don't represent what they do then no one will know what they
are. Of course you will, but that's only for the short week
that you remember scissorLift is an object that
handles menu items. A better name might be
obj_menuHandler
Separate
multiple words by making the first letter of every word a capitol.
Skip capitalizing the first letter of the first word and words that
follow a _. Here is an example:
playerPoints spr_timeLeftGUI
<--- I broke a rule here because there was an
acronym spr_tireMark obj_tankTurret MENU_LOCATION
<---I broke the rules again because this variable is a constant
Use
prefixes to denote the data type. I like to use:
obj_
for objects
spr_
for sprites
scr_
for scripts
snd_
for sounds
tml_
for time lines
pth_
for paths
Use
all caps for variables that do not change; These are called
constants Since
were on the subject of constants, never use "mystery"
numbers. Make a variable for every number you use in your
code. If your still unsure by what I mean look at this:
if
updateMenuLocations = 1 { obj_menuRoot.x =
120 obj_menuRoot.y = 200 }
This is
bad. Instead of "mystery" numbers like 120 and 200,
use constants. The following code is much better.
if
updateMenuLocations = 1 { obj_menuRoot.x =
MENU_LOCATIONS[0,0] obj_menuRoot.y =
MENU_LOCATIONS[0,1] }
MENU_LOCATIONS is a 2d array for all
menu locations. If it was a global variable, all the menus in game would be located in the same position. All directed by a single variable. Also, if you want to change the location of the
menus, you simply change one variable and your done. Or, you
can give the user the ability to customize the menu systems.
You couldn't do that if you used mystery numbers.
Last
but not least is a little theory of mine that I've yet to test.
I'm playing around with the idea that it might be good to name large
or important objects with all capital letters (Just like constants). |