Re: How to name variables in a program?
- From: "Martijn" <subscription-remove-101@xxxxxxxxxxxxxxxxxxx>
- Date: Sat, 28 May 2005 09:28:08 +0200
> Having a strong convention for naming your variables in your program
> is an important issue often overlooked.
> Can anyone point me to a good source on the web dealing with this
> issue?
Ever since I picked up the book Windows programming book by Petzold, I have
been using something called "Hungarian notation":
http://en.wikipedia.org/wiki/Hungarian_notation
Although it is by no means a guide on picking good names for your variables,
this convention works with prefixes to indicate variable type.
When I have a local variable which is nothing more than a temporary variable
I use just the prefix, so unlike what philip states, I do get variable names
such as i and l. To give an example:
i = SomeFunction(szArg1, iArg2, iArg3);
if ( i == 0 )
...;
(note that szArg1, iArg2 and iArg3 are terrible names you should never use
in a real program)
Other conventions I use:
- every structure I define, I trail with a comment indicating the
hungarian code
- prefix global variables with g_
- prefix pointers with lp (this stands for "long pointer" and is still
reminiscent of the 16 bit Windows days)
Good luck,
--
Martijn
http://www.sereneconcepts.nl
.
- Follow-Ups:
- Re: How to name variables in a program?
- From: Phlip
- Re: How to name variables in a program?
- References:
- How to name variables in a program?
- From: SerGioGio
- How to name variables in a program?
- Prev by Date: Re: Advice for mid-life career change (to programming)
- Next by Date: Re: Array Programming Questions
- Previous by thread: Re: How to name variables in a program?
- Next by thread: Re: How to name variables in a program?
- Index(es):
Relevant Pages
|
|