Home >Java >javaTutorial >A brief discussion on the naming convention of java projects in JAVA development

A brief discussion on the naming convention of java projects in JAVA development

无忌哥哥
无忌哥哥Original
2018-07-18 11:54:452176browse

1. Naming specifications

1. The project name is all lowercase

2. The package name is all lowercase

3. The first letter of the class name is capitalized. If the class name consists of multiple consists of words, the first letter of each word must be capitalized.

For example: public class MyFirstClass{}

4. The first letter of the variable name and method name is lowercase. If the name consists of multiple words, the first letter of each word must be capitalized.

For example: int index=0;

Public void toString(){}

5. Constant names are all in uppercase letters

For example: public static final String GAME_COLOR=”RED”;

6. All naming rules must follow the following rules:

1). Names can only consist of letters, numbers, underscores, and $ symbols

2). It cannot start with a number

3). The name cannot use keywords in JAVA.

4). Chinese and pinyin names are strictly not allowed.

2. Annotation specifications

1. Class annotation

A class annotation must be added in front of each class. The annotation template is as follows:

/**
* Copyright (C), 2006-2010, ChengDu Lovo info. Co., Ltd.
* FileName: Test.java
* 类的详细说明
*
* @author 类创建者姓名    * @Date    创建日期
* @version 1.00
*/

2. Attribute comments

must be added in front of each attribute. The comment template is as follows:

/** 提示信息 */
private String strMsg = null;

3. Method comments

in each method A method comment must be added in front. The comment template is as follows:

/**
* 类方法的详细使用说明
*
* @param 参数1 参数1的使用说明
* @return 返回结果的说明
* @throws 异常类型.错误代码 注明从此类方法中抛出异常的说明
*/

4. Constructor method comment

A comment must be added in front of each construction method. The comment template is as follows:

/**
* 构造方法的详细使用说明
*
* @param 参数1 参数1的使用说明
* @throws 异常类型.错误代码 注明从此类方法中抛出异常的说明
*/

5. Method internal comments

Use single-line or multi-line comments inside the method. The comments are added according to the actual situation.

Such as: //Background color

Color bgColor = Color.RED

The above is the detailed content of A brief discussion on the naming convention of java projects in JAVA development. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn