Professional Documents
Culture Documents
LabRequirements v0.3
LabRequirements v0.3
1 Đặt tên biến - Chữ cái đầu của từ đầu tiên phải là chữ thường, chữ cái đầu của từ tiếp theo là chữ hoa
2 Đặ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
3 Đặt tên class cho đúng - Chữ cái đầu của 1 từ là chữ hoa, Tên class phải có ý nghĩa
4 Loại bỏ các import, biến và method thừa sau khi hoàn thành codes
5 Tên method phải bắt đầu bằng động từ, chữ cái đầu của từ đầu tiên là chữ thường, các từ tiếp theo là chữ hoa
6 Đặt tên biến - Là danh từ, phải rõ ràng, tường minh, có ý nghĩa
7 Các biến là thuộc tính của class phải để ở chế độ private
8 Các biến là thuộc tính của class là hằng số phải là chữ hoa - và để final static
9 Các method nếu chỉ dùng bên trong lớp thì phải để là private, dùng trong cùng package thì phải để default, ở lớp ch
10 Trong code sau khi hoàn thành thì ko dùng System.out.print mà phải dùng Logger để out ra console
11 Trước khi xóa hoặc cập nhật dữ liệu cần có màn hình xác nhận
12 Các trường nhập liệu cần có kiểm tra - bắt buộc, thiết lập độ dài
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,