헝가리언 표기법

헝가리언 표기법


 


유래


10,15년 전 Microsoft의 개발자중 헝가리 사람의 프로그래머가 쓰던 변수 명명법.


MS 내부에서 따라 쓰기 시작하던 것이 점차 전세계의 프로그래머들에게 널리 퍼져 프로그램 코딩시 변수 명명의 표준적인 관례가 되었다. 그러나 실제로 현장에서 일하다 보면 헝가리안 표기법을 제대로 지키는 개발자는 그리 많지 않다. 어느 정도 개발 경험을 가지고 있는 프로그래머는 물론 심지어 시중의 프로그래밍 서적에서 조차 저자 마다 변수 명을 개인에 따라 가지 각색으로 짓고 있어서 처음프로그램을 배우는 입문자들이 변수 명명에 대한 기준을 제대로 잡지 못하고 있는 실정이다.


변수 명명에 관한 표준화된 관례를 지켜주면 코드의 가독성을 높여 줄뿐 아니라 어떤 변수 명을 지을지 고민하지 않아도 되는 편리함을 누릴 수 있다.


                         


 :Prefix     :Type                  :Description                                   :Example


:b          :bool                   :any boolean type                           :bool bTrue;


:c          :char                    :character type                              :char cLetter;


:i           :int                      :integer                                         :int iCars;


:l           :long                    :long type                                      :long lDistance;


:u          :unsigned             :unsigned type                            


:f           :float                   :floating point                                :float fPercent;


:d          :double                :double floating point                      :double dPercent;


:s           :static                  :a static variable                           :static short ssChoice;


:rg         :array                   :stands for range                            :float rgfTemp[16];


:p          :*                        :any pointer                                   :int *piAddr;


:sz         :*                       :null terminated string of characters   :char szText[16];


:pfn        :*                        :function pointer                            :int (*pifnFunc1)(int x, int y);


:t           :struct                 :a user defined type


:e          :enum                  :variable which takes enumerated values


:E          :enum                  :Enumerated type


:g_         :Global                 :Global Variable                               :String *g_psBuffer


:m_        :Member               :class private member variable           :


:k           :constant formal parameter                                        :void vFunc(const long klGalaxies)


:r           :reference formal parameter                                       :void vFunc(long&rlGalaxies)


:str        :String                  :string class(C )                          :String strName;


:prg       :dynamically allocated array                                       :char *prgGrades;


:h          :handle                :handle to something                     :hMenu


 


:n          :                           :number, quantity                          :int nNum;


:x/y        :                           :used as size                                 :int xWitdth, yHeight;


 


 


Example of type specific variable naming


unsigned char ucByte;              :한 바이트 데이타


         char cChar;               :한 문자


unsigned char rgucByte[10];           :바이트 데이타10개


         char rgcChar[10];                        :문자 데이터10개


         char szChar[16 1];     :문자16개를 저장할 수 있는 문자열 공간


 


:Data Type           :Description


BYTE               unsigned char type


WORD              unsigned short type


DWORD            unsigned long type



































































접두어


의미


a


배열


b 또는 f


BOOL형 변수(b는 bool, f는 flag의 약자


by


BYTE(unsigned char)형 변수


c


카운터로 사용되는 변수


ch


Char 형 변수


cx, cy


X, Y 길이를 나타내기 위해 사용되는 변수


d


날짜형 변수


dbl


Double형 변수


h


핸들(HANDLE)형 변수


n는 i


Int형 변수


l


Long형 변수


p


포인터변수


lp


Long(far)포인터 변수(32비트 프로그래밍에서는 일반 포인터와 같음)


s


문자열


sz


(NULL)문자로 끝나는 문자열


u


Unsigned int형 변수


w


WORD(unsigned short)형 변수


dw


DWORD(unsigned long)형 변수


str


Cstring 형 변수

댓글

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다