NC -- Naming Conventions

From RAD Studio
Jump to: navigation, search

Go Up to C++ Audits

Description

NC checks whether the code conforms to the naming guidelines. NC controls:

  • Using capitalization of internal elements of compound identifiers when elements are joined without spaces.
  • Using prefixes in identifiers.

NC checks capitalization in the following types of identifiers:

Identifier Type Description

NCCheckClassNames

Class names. The default is PascalCasing.

NCCheckEnumeratorNames

Enumerator names. The default is PascalCasing.

NCCheckFieldNamesConst

Names of unmodifiable fields. The default is PascalCasing.

NCCheckFieldNamesOthear

Names of modifiable fields. The default is PascalCasing.

NCCheckFieldNamesPublic

Names of public fields. The default is PascalCasing.

NCCheckFieldNamesStatic

Names of static fields. The default is PascalCasing.

NCCheckFunctionNames

Function names. The default is CamelCasing.

NCCheckLocalVariablesFormalParameterNames

Names of local variables and formal parameters (arguments). The default is CamelCasing.

NCCheckMacroNames

Names of macros. The default is PascalCasing.

NCCheckMethodNames

Names of methods. The default is PascalCasing.

NCCheckNamespaceNames

Names of namespaces. The default is PascalCasing.


NC understands the following types of capitalization:

CapitalizationType Description

CamelCasing

Each internal element's initial letter capitalized within a compound identifier and the first letter of the identifier is in lowercase, for example, iPod.

LowerCasing

An identifier should contain all letters in lowercase.

PascalCasing

Each internal element's initial letter capitalized within a compound identifier and the first letter of the identifier is in uppercase, for example, BackColor.

UpperCasing

Identifier should contain all capital letters.


NC checks prefixes in the following types of identifiers:

Identifier Type Description

NCPrefixClassFieldNames

In names of fields in classes

NCPrefixClassNames

In names of classes

NCPrefixEnumeratorNames

In names of enumerators

NCPrefixInstanceFieldName

In names of fields in objects

Incorrect

 class myClass {
   static const int max_size = 10;
  
   void MyMethod() {
     int Var;
   }
 };

Correct

 class MyClass {
   static const int MAX_SIZE = 10;
  
   void myMethod() {
     int var;
   }
 };

See Also