pdf.css
Google


   


You are here: CodeIdol > C++ > C/C++ Programming Style Guidelines > page: 6 7 8 9 10 11 12 13 14 15 16


Avoid names that are homophones: e.g.,
foo
,
fu
,
phoo
, etc. Also, don't rely on
capitalization to distinguish between variables.
·
Use names that say what the variable represents rather than how it is used (i.e. use
nouns for variable names); use terminology from the application domain and avoid
computer jargon that reflects programming details.

·
Avoid generic names such as
tmp
,
buf
,
reg
.
·
Avoid intentionally misspelled words such as
lo
or
lite
.
In general, short names are acceptable for variables that serve a short-lived purpose or
that have a common usage in C/C++ (e.g., index variables called

i
,
j
,
k
, etc.). Being
concise can contribute to the readability of code. However, for variables that serve a
unique and important purpose, or variables that persist over a significant region of your
code, use descriptive and complete names. Studies have shown that minimal debugging
time correlates with average variable name lengths of 10-16 characters.

4.2. Function Names
Use lower-case letters for public function names. Use an underscore as a word
separator.

For functions that return no values (i.e. return type
void
), use strong verbs that indicate
the function's purpose. Typically you will want to include the object of the verb in the
name. For example,

void
remove_dc_offset(short *signal, const unsigned long length);
void
set_output_gain(const float gain);
Because functions tend to serve a more complex purpose than variables, longer names
are more acceptable.

You are here: CodeIdol > C++ > C/C++ Programming Style Guidelines > page: 6 7 8 9 10 11 12 13 14 15 16


ADBRITE ads links
   
Related tags







Popular Categories
Unix books and guides

AJAX popular information
C# language guides
Windows books and cookbooks

.......








Business Key Top Sites

be number one
rate your site




    С 2009 года мы стали переводить структура сайта на различные языки. Сайт теперь будет содержать книги не только на английском языке, но также и на других европейских языках, в том числе и на Русском языке.

    Русский Polski Francais Deutsch
    support sitemap terms

© CodeIdol Labs, 2007 - 2009