Node:Variable and function names, Next:Declarations and initialization, Previous:Comments and style, Up:Style
Variable and function names
The names of variables and functions in a program serve as comments of
a sort, so try to give your variables descriptive names (for example,
num_of_books
, cost_per_entry
, or
distance_from_center
). Names should be in English, like other
comments.
Use underscores rather than internal capitalization in names, so that
Emacs word commands can be useful within them -- thus
distance_from_center
rather than distanceFromCenter
or
DistanceFromCenter
. In fact, upper-case letters should be
reserved for macros and enum
constants. Macros should be
completely in upper case, for example STANDARD_SIZE
.
It used to be common practice to use the same local variables
(with names like temp
) over and over for different purposes
within one function. Instead, it is better to declare a separate local
variable for each distinct purpose, and give it a meaningful name.
This not only makes programs easier to understand, it also facilitates
optimization by good compilers.