TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
C++ Coding Standard
Search

Category: Naming

Synopsis:Naming Conventions


Description:

This chapter concerns the naming of abstractions used in the code. Names are important for readability and maintainability of the code. By applying naming conventions, code is more comprehensible for others, be it now during development or at a later stage during maintenance. In general, this means that the maintainability and quality of the code increases.

In this chapter, it is important to distinguish between identifiers and names. The name is that part of an identifier that shows its meaning. An identifier consists of a prefix, a name, and a suffix (in that order). The prefix and the suffix are optional. A suffix is only used by tools that generate C++ code, to avoid name collisions with user-written C++ code and is not given further consideration here.

Coding Rules

NameCheckedSynopsis
NAM#001 Use US English names for identifiers
NAM#002 Checked automatically with code checker Do not use identifiers which begin with an underscore ('_') followed by a capital
NAM#003 Checked automatically with code checker The names of user defined types, enumerators, typedefs, typenames and class templates are in PascalCase
NAM#004 Checked automatically with code checker In names which consist of more than one word, the words are written together and each word that follows the first is begun with an uppercase letter
NAM#005 Checked automatically with code checker The names of data members and member functions are in PascalCase
NAM#006 Checked automatically with code checker The names of formal arguments to methods/functions should be specified and should be the same both in the declaration and in the definition
NAM#007 Accessor method names should correspond with the attribute being accessed
NAM#008 Checked automatically with code checker Do not use identifiers that contain two or more underscores in a row
NAM#009 Use meaningful names
NAM#010 Be consistent when naming identifiers
NAM#011 Names should not include abbreviations that are not generally accepted
NAM#012 Prefix macros in include files with their module's basename in uppercase, followed by an underscore and further uppercase characters
NAM#013 Prefixes for exported functions, structures, enumerations and macros consist of unit id and optionally module id
NAM#014 Checked automatically with code checker The names of internal or local variables and internal functions are in camelCase
NAM#015 Checked automatically with code checker Use Pascal and Camel casing for naming indentifiers