ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 헝가리언 표기법
    안드로이드/Tip 2011. 5. 8. 02:56

    헝가리언 표기법 (Hungarion notation)

     

    1) Code Converntion (헝가리언 표기법)
    a : Array
    b : BOOL
    ch : Character
    cb : Count of bytes
    dw : unsigned long DWORD
    h : Handle
    i : Index
    l : long int
    lp : long(far) pointer
    n : int
    sz : NULL로 끝나는 문자열
    w : unsigned int WORD

     

    2) 사용빈도가 높은 메시지와 관련 스타일
    BM_ : 버튼메시지
    CB_ : 콤보박스 메시지
    DM_ : 대화상자 메시지
    EM_ : 에디트 컨트롤 메시지
    LB_ : 리스트 박스 메시지
    WM_ : 윈도우 메시지
    BS_ : 버튼 스타일
    CBS_ : 콤보박스 스타일
    DS_ : 대화상자 박스 스타일
    ES_ : 에디트 컨트롤 스타일
    LBS_ : 리스트 박스 스타일
    WS_ : 윈도우 스타일

     

    3) Windows에서 자주 사용하는 데이터형
    BOOL  : true, false
    BYTE  : 8비트 unsigned 정수
    COLORREF : 색상을 표현하는 32비트 데이터 형
    DWORD  : unsigned long int 형
    LPARAM  : 32비트 메시지 파라메터
    WPARAM  : 32비트 메시지 파라메터
    LRESULT  : 메시지 처리에 대한 결과를 나타내는 32비트 정수
    UINT  : 32비트 unsigned형 정수
    LPSTR  : char string의 32비트 포인터, char* 와 같음
    LPCTSTR  : Constant character string의 32비트 포인터
    LPCTSTR  : Unicode와 DBCS를 위한 Constant character string의 32비트 포인터

     

     

     

    x_xXxxxxxx

    0123456789

    0 : 변수의 위치를 지정한다. g(전역변수), m(멤버변수), 없음(지역변수)
    1 : 0 위치에 g 나 m 을 지정한 경우 _ 을 기술한다.
    2 : 자료형의 종류를 나타낸다. 
        n, i : 정수형(n은 카운트 목적, i는 인덱스 목적)

        l : long 형

        u : 부호없는 정수형 
        w : 부호없는 2byte 정수형
        dw : 부호없는 4byte 정수형
        p : 포인터 타입
        f, d : 실수형(f는 float, d는 double)
        sz : char 배열(문자열 표현)
        클래스 이름에 대해서는 관습적으로 자음축약형을 사용한다.
    3 ~ : 변수의 의미 있는 이름을 기술하며, 3 위치는 대문자를 사용한다. 변수 이름이 너무 긴 경우 자음만을 기술한다. 예) g_nCnt

     

     

     

    :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

     

    댓글

COPYRIGHT 2010 EpoNg. ALL RIGHTS RESERVED.