65.9K
CodeProject is changing. Read more.
Home

Programming conventions

starIconstarIconstarIconstarIconemptyStarIcon

4.00/5 (4 votes)

Mar 26, 2002

1 min read

viewsIcon

159495

Some programming convention tables for reference

Introduction

This is less of an article, more of a reference sheet to be printed out and stuck to the wall.

Hungarian Notation

"Hungarian notation" was developed by Hungarian Charles Simonyi of Microsoft ™, hence the name. Most programmers seem to stick to a flavour they like or develop a different flavour. This is a starting point for those who wish to use it. Add extra ones in the blank rows as you see fit.

Data Type

Prefix

Example

Boolean

b

bContinue

Int

n

nIndex

Short

n

nIndex

Character

c

cFirstInitial

Float

f

Percent

Double

d

dMetres

Long

l

lCarCount

String

s

sCustomerName

Null terminated String

sz

szCustomerName

Unsigned Integer (Word)

w

wCount

Unsigned long integer (DWORD)

dw

dwAtomCount

Pointer

p

pNext

Handle

h

hWnd

Function

fn

fnReport

Class

C

CParser

Class member variable

m_

m_

Array

a

aYears

Global

g_

g_szDirectory

Windows message

Msg

msgCut

You can add some of the prefixes together where they make sense.

  • For example a member variable which is a null terminated string , "m_szName".
  • Another might be for a global integer eg. "g_nElementCount".

Windows Resources

Resource Type

Prefix

Example

Menu Item Resource

ID_

ID_EDIT_CUT

String

IDS_

IDS_STRING1

Dialog Control

IDC_

IDC_EDITBOX

ICON

IDI_

IDI_MAINICON

Cursor

IDC_CURSOR_

IDC_CURSOR_ARROW

Dialog Box

IDD_

IDD_ABOUTBOX

Accelerator

IDR_

IDR_ACCELERATOR

Bitmap

IDB_

IDC_ARROW

Free free to email me your updates/suggestions and I will update the article as necessary.