Jump to content

User:MarkMYoung/code naming conventions

From Wikipedia, the free encyclopedia

Code Naming Conventions

[edit]

These conventions are not strictly held, but they are the common direction I take when code requires disambiguation.

Scopes

[edit]
  • g_: global scope (rarely applicable)
  • k_: class scope (i.e. static)
  • l_: local scope (rarely applicable)
  • m_: object scope

Modifiers

[edit]
  • _a: array modifier
  • _p: pointer modifier
  • _r: reference modifier
  • _u: unsigned modifier (signed is default, except in the case of char which is neither signed nor unsigned by default)
  • _o: pointer/reference to a function/method instance

Types

[edit]
  • _b: boolean type
  • _c: char type
  • _d: double type
  • _e: enumerated type
  • _f: float type
  • _h: hash/associative array/dictionary type
  • _i: int type
  • _l: long type
  • _s: short type
  • _v: void type
  • _x: byte type

Others

[edit]
  • _exc: exception type
  • _func: function instance
  • _obj: general object
  • _regexp: pre-compiled regular expression
  • _str: string type

Examples

[edit]
  • A global array of enumerated client (finite) states (C):

ClientState g_clientStates_ae[ ClientState.m_stateCount_ui ];

  • An object member pointer to an unsigned integer that holds the reference count of objects sharing data (C/C++):

unsigned int* m_referenceCount_pui;

  • A (static) class member to a method accepting no arguments and returning a boolean value (C/C++):

static bool (k_methodName_bov*)( void ) = g_methodName_func;