웹마짱구's 블로그

프로그래밍 표기법

참고/기타참고 : 2007/08/31 16:20


원문 : http://blog.naver.com/neptune16/80026989952 

파스칼 표기법 : ClassName  - 각 단어의 첫번째 문자를 대문자로 표기

카멜 표기법 : nameSpace - 첫번째 단어를 제외한 각 단어의 첫번째 문자를 대문자로 표기

헝가리안 표기법 : strName -

사용자 삽입 이미지


헝가리안 표기법이(Hungarian Notation)란


변수 선언시 접두어를 붙여 변수의 의미를 명확하게 하기 위한 규칙이다.

마이크로소프트의 프로그래머 Charles Simonyi가 코딩할때 습관적으로 즐겨쓰던


접두사 변수 명명 방식이 빌 게이츠의 눈에 띄어 표준화된 것이다.


"헝가리안 표기법"으로 불리는 이유는 Charles Simonyi가 헝가리에서 이민 온 사람이었기


때문이다. 변수 이름만으로도 많은 정보를 한 눈에 알아볼 수 있어 오류를 획기적으로 줄여


주는 것으로 유명하다.


그래도 버릇들이는 게 앞으로 코딩을 하는 데 좋겠다 싶다. 나 혼자 작업할 것도 아니니까.


Hungarian Notation

Data Type

Prefix

Example

Boolean

b

bContinue

Int

n

nIndex

Short

n

nIndex

Character

c

cFirstInitial

Float

f

fDistance

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



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

 



 

접두어    의미
a    배열
b 또는 f    BOOL형 변수(b는 "bool", f는 "flag"의 약자)
by    BYTE (unsigned char)형 변수
c    카운터로 사용되는 변수
ch    char형 변수
cx, cy    x, y 길이를 나타내기 위해 사용되는 변수
d    날짜형 변수
dbl    double형 변수
dw    DWORD(unsigned long)형 변수
f    float
fn    함수
g_    global 변수
h    HANDLE 형 변수
hwnd    HWND(WINAPI)
i 또는 n    정수(int)형 변수
l    long형 변수
m_    class의 멤버 변수
p    포인터 변수
pv    Void pointer
pt    Point struct(WINAPI)
r 또는 rc    RECT struct(WINAPI)
s    문자열
str    CString 형 변수
sz    NULL로 끝나는 문자열(사실상 그냥 문자열 -_-;)
u    unsigned int형 변수
w    WORD형 변수

[예제]

g_pszVarName : global pointer to a null-terminated string named VarName

apfValues : local array of pointers to floats named Values

pafValues : local pointer to an array of floats named Vaues

m_hwndParent : member HWND named Parent

출처 : Tong - sjpotato님의 + VC++통



top

참고/기타참고 : 2007/08/31 16:20 Trackback. : Comment. : view 1374

Trackback Address :: http://jjangu.pe.kr/blog/trackback/452

Write a comment.




: 1 : ... 143 : 144 : 145 : 146 : 147 : 148 : 149 : 150 : 151 : ... 543 :