Java Development Specification

Source: Internet
Author: User

HBH Development Specification Documentation

One: Purpose

Enable the organization to design and encode in a standard, normative manner. By establishing coding specifications so that each developer

Develop a good coding style and habits, and to form a development team coding conventions, improve the reliability of the program, readability,

Can be modified, maintainability and consistency, improve communication between teams, and ensure the quality of software products.

Two: Code organization and style

1: Length: For readability and comprehension, the effective code length of a single function is as far as possible within 100 lines (excluding lines),

When the function module is too large, it is often used to extract the corresponding function using the sub-function, which also helps to improve the reuse of code.

2: Interval: class, method and function block should be separated by a blank line to increase readability, but there should be no irregular large blank lines. Each end of the operator should be empty one character to increase readability.

Three: Notes

1: Comments should increase the clarity of the code. The purpose of the code comment is to make the code easier to understand by other developers.

2: Keep the annotations concise.

3: Annotation information should include the functionality of the code.

4: Comments with shorter statements, such as variable definitions, use end-of-line comments, and other comments when avoiding line-ending annotations

5:javadoc specification

Comments on classes, methods, variables, etc. need to conform to

Javadoc specification, for each class, method should be detailed description of its functional conditions, parameters and so on.

1) class, interface annotations

Before the class, the interface is defined before it is commented, including the class, the purpose of the interface, function, function, inherited from which parent class, implementation of the interface, implementation of the algorithm, use of methods, sample programs, etc.

2) Method comments

To clarify the function of the method, the meaning of each parameter and the return value.

3) Other comments

The important variables and difficult-to-understand branch conditional expressions should be commented to explain their meanings and so on.

Four naming conventions

1: The names of variables, classes, interfaces and packages should be in English or Chinese initials. It is also not possible to use Chinese characters for naming. Use mixed case to improve the readability of the name. Generally lowercase letters should be used, but the first letter of the name of the class and interface, and the first letter of any intermediate word should be capitalized. The package name is all lowercase.

2: Minimize the use of abbreviations, but if must be used, when the use of public abbreviations and customary abbreviations, such as implement can be reduced to Impl,manager can be reduced to write Mgr and so on.

3: The package name is usually named after the project or module name, less abbreviations and long names, all lowercase. The package name constitutes [Basic package] According to the following rules. [Project name]. [Module name]. [Sub-module name] ... such as: Org.skyinn.skyhome.dao.hibernate. You must not define a class directly under the base package, and all classes, interfaces, and so on in the project are defined in the respective project and module packages.

4: Class, interface

Capitalize all the words in the first letter, preferably in the name of a known meaning. Nouns or Chinese initials are generally used. or Able,dao,dto,bean suffix.

5: Field

Constants use a complete English capital word, with underscores connected between words, such as default_value.

6: Variables and parameters for variables that are not easy to identify the variable type should be prefixed with the type abbreviation, such as String using Strxxx,boolean isxxx,hasxxx and so on. Capitalize the first letter of the remaining words except the first word.

7: Collection

A plural name is used to represent the type of object held in the queue, and nouns are described in full English. For example: vector vproducts= new vector (); Array aryusers= new Array ();

8: Method

The name of the method should be described in full English, mixed in case: capitalize the first letter of all intermediate words. The first word of the method name often takes a verb with a strong action color. The value class uses the Get prefix, which sets the class so that the set

Prefix. For example GetName (), Setsarry ().

9: The exception class name consists of words and exception that represent the exception type, such as Actionexception. Exception instances generally use E,ex and so on.

10: Naming the array

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

Special provisions on the HBH project:

A. Controller layer specification:

1. The query class interfaces in the controller layer all start with quary*. Query local use Quarylist. Check the quaryzdlist in the log.

2. The class interface at the controller layer is all prefaced with to*. Query local use Tozzh.

3. The URL address is usually the method name. If there is a special case. Communicate with the author of this specification. and added to this specification.

Java Development Specification

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.