Java project development FAQ
1. Developers:
(1) The package name should be in lowercase.
(2) Class Name: It is composed of English words. Each word has an upper-case letter and preferably no more than four words.
(3) variable naming:
Class variable name: lowercase letters, followed by uppercase letters.
Static and final variable naming: all variable names are in uppercase and indicate the complete meaning.
Name variables with meaningful names. Chinese characters are not allowed.
Name Collection variables in the plural.
(4) method naming:
Lowercase letters, followed by uppercase letters.
The method name should be related to the purpose of the method.
(5) parameter naming:
The name of a parameter is the same as that of a variable.
Method parameters: Use a meaningful parameter name. If possible, use the same name as the value field.
(6) CSS naming:
Create different CSS files for different deployment function applications.
(7) code format:
File Header: copyright information, package/import
|
/**
* $ ID: iusermodule. Java, v1.3 2014/4/18 11:23:00 am zhangsan $
* Copyright (c) 2006 China
*/
PackageCom. activemq. test;
/**
*@ Title: Iusermodule. Java
*@ Description:
*@ Company:
*@ AuthorLiu hongping
*@ CreatedOn: 11:16:00 AM
*@ VersionV1.0.0
*/
Public InterfaceIusermodule {
} |
Indent: four spaces in each line.
NOTE: For the smooth generation of Java Doc, standard Java annotations are added before development methods and global variables.
2. Problems Affecting Performance and system stability:
(1) database operations:
After the business is completed, the database connection is not closed,
Statement/resultset not closed
Database Transaction usage: ensure that the business logic is completed and then committed.
Minimize the transaction time. The operations in the transaction segment only involve the relevant operation code, and other searches should be separated.
(2) The file stream is not closed:
(3) do not copy an unchangeable object. For example, if the content of a string object must be changed, it can be changed through stringbuffer.
(4) stringbuffer objects should be used for string operations.
(5) Avoid using synchronized too much.
3. programming errors:
(1) NULL pointer exception: mainly related to object operations.
(2) An error occurred while formatting a number. When any string is converted to a number, an exception is caught. Robust modules
(3) string out of bounds. First, judge whether it is null and the length before intercepting and other operations.
(4) No exception is found in the class definition. On the one hand, you can re-upload and restart the server.
(5) The equals, hascode, or clone method is not implemented correctly.