Professional Documents
Culture Documents
JavaWeb CheckList v0.2
JavaWeb CheckList v0.2
class phải đưa vào package và Đặt tên package cho đúng - là danh từ, chữ thường, có ý nghĩa tương ứng với các lớp trong package
tên class cho đúng - Là danh từ, Chữ cái đầu của 1 từ là chữ hoa, Tên class phải có ý nghĩa,
ng filter class để xác nhận, kiểm tra quyên truy cập
ng SessionListener để đếm lượt View trang
ng TextFormat/NumberFormat để format lượt view (có định dạng 6 chữ số)
trường nhập liệu cần kiểm tra
Set max length hoặc kiểm tra độ dài
Kiểm tra trường bắt buộc
Kiểm tra định dạng nếu các trường có kiểu dữ liệu là Number, Date, Email, hoặc Phone no
Kiểm tra trường khi người dùng chỉ nhập space (dấu cách)
Loại bỏ dấu cách hai đầu (trim) dữ liệu trước khi lưu
thuộc tính của lớp cần để quyền truy cập là private
method có sử dụng connection, prepare statement, result set cần có đóng con trỏ trong finally {} và tuân thủ nguyên tắc mở trước đóng s
ứng dụng đều cần có trang lỗi để hiển thị khi có lỗi hệ thống hoặc các lỗi chưa biết trước
lớp ở tầng business logic (BO) hoăc DAO (truy cập cơ sở dữ liệu) cần throw exception ra tầng trên (tầng Servlet)
hoàn thành code, không sử dụng System.out.print để out log mà Sử dụng Logger của JDK để ghi log
khi hoàn thành code cần loại bỏ hết các câu lệnh import mà các class được Import lại không được sử dụng (loại bỏ import thừa)
O class cần extends từ DBContext, DB Connector hoặc BaseDAO hoặc class cha có các method chung để kết nối với DB Server
method là động từ, chữ cái đầu của từ đầu tiên là chữ thường, chữ cái đầu các từ tiếp theo là chữ hoa
tên constant phải là chữ hoa và phải khai báo là final static
mat code cho đúng convention của Java
biến Connection, PreparedStatement, ResultSet không khai báo là attribute of class
i comment codes trong các dòng lệnh, class header và trên header của method
biến phải tường minh có ý nghĩa (sát với ý nghĩa biến dùng để làm gì), chữ cái đầu tiên là chữ thường, chữ cái đầu của từ tiếp theo phải là
DAO class cần có các lớp Interface, các lớp Servlet sử dụng các Interface để khai báo các biến DAO
khai báo biến, chỉ khai báo 1 biến trên 1 dòng (xem sheet Declarations)
<Class Name 1> <Class Name 2>
Not passed Not passed
Not passed Not passed
/*
* Copyright(C) 2005, <Name of Organization/Individual own the application>.
* <ProjectCode/Short Name of Application> :
* <Full name of project code/Name or application>
*
* Record of change:
* DATE Version AUTHOR DESCRIPTION
* <yyyy-MM-dd> <x.x> <Name of author> <Description of changes>
*/
Ví dụ
/*
* Copyright(C) 2005, Morses Club of London Scottish Bank.
* T.NET:
* Transport and Information Network
*
* Record of change:
* DATE Version AUTHOR DESCRIPTION
* 2018-09-10 1.0 MinhLH First Implement
*/
/**
* (Write a succinct description of this class here. You should avoid
* wordiness and redundancy. If necessary, additional paragraphs should
* be preceded by <p>, the html tag for a new paragraph.)
*
* <p>Bugs: (a list of bugs and other problems)
*
* @author (your name)
*/
Ví dụ
/**
* Lớp này có các phương thức thực hiện truy vấn hoặc cập nhật dữ liệu từ bảng
* Staff. Trong các phương thức update or insert của lớp, dữ liệu được chuẩn hóa (loại bỏ dấu cách ở hai đầu) trước khi được cập
* Các phương thức sẽ trả về một đối tượng của lớp <code>java.lang.Exception</code> khi có bất cứ lỗi nào xảy ra trong quá trì
* <p>Bugs: Còn lỗi liên quan đến việc truy vấn nhân viên theo tên và địa chỉ
*
* @author Nguyen Van Hoang
*/
/**
* The class contains method find update, delete, insert staff information from
* Staff table in database. In the update or insert method, all data will be normalized (trim space) before update/insert into databa
* The method wil throw an object of <code>java.lang.Exception</code> class if there is any error occurring when finding, inse
* <p>Bugs: Still have some issues related to search staff by address
*
* @author Nguyen Van Hoang
*/
Lưu ý
1 Dùng thẻ <br> hoặc <p> cho vào cuối các dòng để tránh khi format code bị thay đổi định dạng
2 Viết chính tả và ngữ pháp cho comments. VD: Như
Class/interface bắt đầu 1 câu thì chữ cái đầu của từ đầu tiên phải viế
implementation
3 Dùng /* */ comment (khi không muốn các comment này được đưa vào java doc
ách ở hai đầu) trước khi được cập nhật vào cơ sở dữ liệu
bất cứ lỗi nào xảy ra trong quá trình truy vấn, cập nhật dữ liệu
Ví dụ
/**
* Find the staff by staff name and date of birth. All the staffs matched wild card with staff name and having date of birth >= the
* The result contain a list of <code>vn.co.fu.bean.Staff </code> objects with name, DOB, addess, and mobile no attributes
*
* @param staffName the name of a staff. It is a <code>java.lang.String</code> object
* @param dob the date of birth. It is a <code>java.util.Date</code> object
* @return a list of <code>Staff</code> objects. It is a <code>java.util.List</code> object
*/
Lưu ý
1 Dùng thẻ <br> hoặc <p> cho vào cuối các dòng để tránh khi format code bị thay đổi định dạng
2 Viết chính tả và ngữ pháp cho comments. VD: Như bắt đầu 1 câu thì chữ cái đầu của từ đầu tiên phải viế
e and having date of birth >= the input DOB will be returned
ess, and mobile no attributes
/*
* Here is a block comment.
*/
/*
* Here is a block comment with some very special
* formatting that I want indent(1) to ignore.
*
* one
* two
* three
*/
he rest of the code.
he first.
A) Single-Line Comments
B) End-Of-Line
text comments;Comments
however, it can be used in consecutive multiple lines for commenting out
sections of code. Examples of all three styles follow:
if (foo > 1) {
// Do a double-flip.
...
}
else
return false; // Explain why here.
//if (bar > 1) {
//
// // Do a triple-flip.
// ...
//}
//else
// return false
C) Trailing Comments
if (a == 2) {
return TRUE; /* special case */
} else {
return isprime(a); /* works only for odd a */
}
Number Per Line
One declaration per line is recommended since it encourages commenting. In other words,
int level; // indentation level
int size; // size of table
is preferred over
int level, size; WRONG
. In other words,