Archived

This topic is now archived and is closed to further replies.

xegoth

good variable naming practices

Recommended Posts

Hey, I''m pretty experienced at C++ but just started coding again and haven''t done it in a while.. I''ve found the thing I forgot were all the good habits for naming variables. (Should globals be all caps?? Is it bad to use shift in variable names??)E.g. ShipLocationX. All that stuff used to be second nature to me, but now I''m butchering my projects by being very inconsistent with naming practices. Can anyone point me to a good article on the subject to refresh my memory? Thanks in advance.

Share this post


Link to post
Share on other sites
i usually do this:

for integers:
intVarName

booleans:
boolVarname
edit: blnVarName

double:
dblVarName
single:
sngVarName

for private variables
_varname //use the prefixes mentioned above too
public variables
VarName //use the prefixes mentioned above too

btw in ur example u said ShipLocationX, just create a point(this is vb, im not sure about C++)
Dim pntShipLocation As Point
//later in ur code:
pntShiplocation.X = something
pntShipLocation.Y = something

i thjink in C++ it would look like
Point pntShipLocation;
pntShipLocation->X = something;
pntShipLocation->Y = something;

(not too sure about the C++ tho)

[edited by - The Pentium Guy on March 19, 2004 5:46:03 PM]

Share this post


Link to post
Share on other sites