본문 바로가기

Note..

JAVA 이름규칙



Identifier Type


Rules for Naming


Examples


Packages


The prefix of a unique package name is always written in all-lowercase ASCII letters and should be one of the top-level domain names, currently com, edu, gov, mil, net, org, or one of the English two-letter codes identifying countries as specified in ISO Standard 3166, 1981.

Subsequent components of the package name vary according to an organization's own internal naming conventions. Such conventions might specify that certain directory name components be division, department, project, machine, or login names.

com.sun.eng

com.apple.quicktime.v2

edu.cmu.cs.bovik.cheese


Classes


Class names should be nouns, in mixed case with the first letter of each internal word capitalized. Try to keep your class names simple and descriptive. Use whole words-avoid acronyms and abbreviations (unless the abbreviation is much more widely used than the long form, such as URL or HTML).


class Raster; 
class ImageSprite;


Interfaces


Interface names should be capitalized like class names.


interface RasterDelegate; 
interface Storing;


Methods


Methods should be verbs, in mixed case with the first letter lowercase, with the first letter of each internal word capitalized.


run(); 
runFast(); 
getBackground();


Variables


Except for variables, all instance, class, and class constants are in mixed case with a lowercase first letter. Internal words start with capital letters. Variable names should not start with underscore _ or dollar sign $ characters, even though both are allowed.

Variable names should be short yet meaningful. The choice of a variable name should be mnemonic- that is, designed to indicate to the casual observer the intent of its use. One-character variable names should be avoided except for temporary "throwaway" variables. Common names for temporary variables are ijkm, and n for integers; cd, and e for characters.


int i; char c; float myWidth;




Constants


The names of variables declared class constants and of ANSI constants should be all uppercase with words separated by underscores ("_"). (ANSI constants should be avoided, for ease of debugging.)


static final int MIN_WIDTH = 4;

static final int MAX_WIDTH = 999;

static final int GET_THE_CPU = 1;


(원문 : http://www.oracle.com/technetwork/java/codeconventions-135099.html#367 )


기본적인 이름규칙.


Packages : 

최상위 패키지는 모두 소문자로 도메인 (com, edu, gov, mil, net, org..) 이거나 국가코드

그 이후는 조직의 내부규칙에 따름. 예를들어 특정 디렉토리 이름, 구성요소의 분할(?), 부서, 프로젝트, 머신, 로그인 이름 등으로 지음


Classes :

명사이며 대문자로 시작한다. 조합된 단어일경우 단어의 첫글자를 대문자로한다. URL, HTML같이 흔히쓰는 약어가 아니면 풀어서쓴다.


Interfaces :

클래스와 같음


Methods :

동사이며 소문자로시작. 단어의 조합일 경우 두번째 단어부터 첫글자를 대문자로한다.


Variables :

소문자로 시작하고 단어의 조합일경우 두번째 단어부터 첫글자를 대문자로한다. 언더라인(_), 달러($)로 시작하지 않고, 되도록 짧으며 보는사람이 사용의도를 파악할 수 있게 의미를 지녀야한다. 일회성변수가 아니라면 한단어로 변수를 명명하지 않는다.


Constants :

모두 대문자이며 단어의 조합일경우 _로 구분한다.


'Note..' 카테고리의 다른 글

[DB] Newheart Academy DB - 1주차 ppt  (0) 2013.02.08
MyISAM vs INNODB  (0) 2013.02.07
git 1  (0) 2012.08.25
opencv 세팅  (0) 2012.07.11
mfc 레퍼런스 사이트  (0) 2012.06.22