Java code development specification

I Development tool specification:

1. The development tools shall be uniformly determined after debugging by the project leader.

2. Once the development tool is determined, it is not allowed to integrate any non-uniform plug-ins. If necessary, it can be added uniformly for the members of the project team with the consent of the project leader.

3. The coding format of the development tool cannot be modified.

II Typesetting specification:

1. Add a space between keyword (or variable) and operator. For example: int icont = 1// There is a space between the operator and the value.

2. Add blank lines between relatively independent code blocks. For example, two methods need to be separated by spaces.

3. Long sentences and expressions should be written in multiple lines.

4. The long expression should be divided into new lines at the low priority operator, and the operator should be placed at the top of the new line.

5. Indent the new line of code and the previous line according to the logical relationship (a table key) to make the layout neat and the statement easy to read.

6. It is not allowed to write multiple phrase sentences in one line, that is, only one sentence in one line.

7. The code in the beginning of function or process, the definition of structure, loop, judgment and other statements shall be indented. Indent with the table key.

8. If there is a long expression or statement in the statements such as loop and judgment, it shall be divided appropriately.

9. If the parameters in the function or process are long, they should be divided appropriately.

10. When defining a program block with curly braces' {'and'} ', when writing the program block' {'and'} 'should each have an exclusive row and be in the same column, and be aligned to the left of the statement referencing them. The above indentation method shall be adopted for the program at the beginning of function body, class definition, structure definition, enumeration definition and if, for, do, while, switch and case statements.

Java code development specification (wishsoft)

11. Main method: if the main (string []) method has been defined, it should be written at the bottom of the class

III Naming conventions:

1. Naming of package

Package names should all consist of a lowercase word. For example: package com wish;

2. Naming of class

The name of class must consist of words that begin with uppercase letters and all other letters are lowercase. For all identifiers, its

All words contained in should be close together and capitalized with the first letter of the middle word. For example:

public class DatabaSEOperator { }

3. The name of the named variable of the member variable in class must start with a lowercase letter, and the subsequent words must start with an uppercase letter, which does not need to be preceded by the data type

Affix. For example: username, size.

4. Naming of static final variable in class

The names of static final variables should be capitalized and indicate the full meaning.

For example:

public static final String DB_ CONfig_ FILE_ PATH ="com.neu.etrain.dbconfig";

5. The name of the method in class must start with a lowercase letter, and the following words must start with a capital letter. For example: setname(), getmethod().

6. In the method declaration, the parameter name should be meaningful. If possible, use the same name as the field to be assigned. For example:

public void setCounter(int size) {

Java code development specification (wishsoft)

this. size = size; }

7. Naming of variables in the method

Name of member variables in class.

8. Array naming

Arrays should always be named in the following way: byte [] buffer; Instead of: byte buffer [];

9. The variable of the number of lists per page in paging uses PageSize, and the current page number is PageNumber.

IV Note specification:

1. The notes should be simple and clear.

2. Comment while writing the code, modify the code and modify the corresponding comments to ensure the consistency between the comments and the code.

3. Make notes where necessary, and the amount of notes should be moderate. The content of the notes shall be clear, clear and accurate to prevent ambiguity. Keep annotations adjacent to the code they describe, that is, the proximity principle of annotations.

4. The notes of variables and constants should be placed above or to the right, not below.

5. The global variable shall be annotated in detail, including its function, value range, which functions or processes access it and precautions during access.

6. Class and method annotations are generated automatically by eclipse.

After completing the declaration of a class or method, enter: / * * directly above the class or method (no spaces are allowed) in the English input method status, and the system will automatically generate their annotation template. We only need to fill in the corresponding description text. Note: the function description must be written in the next line of: / * *.

7. Specific requirements:

N declarative (variable definition class) must be annotated. For example: String myname// The user name n class definition must generate a document (Javadoc) comment.

N method must generate document (Javadoc) comments (including set and get methods of entity classes). N member variables must generate document (Javadoc) comments.

The logic part of N method is written by the programmer according to the complex situation.

8. Annotation information of class definition, including: author; Date; Module function description (such as function, main algorithm, internal departments)

Relationship between sub documents, relationship between this document and other documents, etc.); Historical modification records of this document; Version information, etc.

/*** for what (descriptive information)

Java code development specification (wishsoft)

*@ author lifw20080320 * @ modify lifw20080321 * @ modify lifw20080322 (if there are multiple, write multiple @ modify) * @ Copyright wishsoft**/

9. Javadoc annotation label syntax

@The author's description of the class indicates the author who developed the class module

@Version the description of the class indicates the version of the module of the class

@See refers to the description of classes, attributes and methods, that is, the description of the method in the related topic @ param and the description of a parameter in the method

@Return description of the method description of the returned value of the method

@Exception describes the method and describes the exceptions that may be thrown by the method

V Basic data type prefix table (other object types, supplemented at any time):

Vi Log component usage specification (log4j)

1. Use of methods in log:

a) log. Debug () is placed in the middle of the code line and used for output during debugging. It is permanently retained and does not need to be deleted.

b) log. Error () is placed in the catch section of try {} catch () {} to output error exception information.

The above is the whole content of this article. I hope the content of this article can bring some help to your study or work. At the same time, I also hope to support a lot of programming tips!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>