You are on page 1of 38

Ho Chi Minh City University of Technology - VNUHCM

Course: Software Testing Class: L01 Semester 1 - Year 2021-2022


Code Review Campaign - 02-Oct-2021

Group name: BugBugBug


No. Family name First name Student Code Role Contribution
1 Nguyễn Hồng Nhân 1813330 Leader 20%
2 Trần Đăng Khoa 1812665 Member 20%
3 Nguyễn Đình Phúc 1813570 Member 20%
4 Trần Phương Tĩnh 1927038 Member 20%
5 Trần Ngọc Yên 1814872 Member 20%
Job
53-64 Tất cả các file
16-26 Tất cả các file
27-38 Tất cả các file
1-15 Tất cả các file
39-52 Tất cả các file
Check Code Check code description
I - DEVIATION OBJECTIVE
# I.1 – DEVIATION
1 Does the code correctly implement the design?
2 Does the code implement more than the design?
3 Is every parameter of every method passing mechanism (value or reference) appropriate?
4 Does every method return the correct value at every method return point?
II – OMISSION OBJECTIVE
# II.1 –OMISSION
5 Does the code completely implement the design?
III - DEFECT OBJECTIVE
# III.1 – Variable and Constant Declaration
6 Are descriptive variable and constant names used in accord with naming conventions?
7 Is every variable correctly typed?
8 Is every variable properly initialized?
9 Are all for-loop control variables declared in the loop header?
10 Are there variables that should be constants?
11 Are there attributes that should be local variables?
12 Do all attributes have appropriate access modifiers (private, protected, public)?
# III.2 – Method Definition
13 Are descriptive method names used in accord with naming conventions?
14 Do all methods have appropriate access modifiers (private, protected, public)?
15 Is every method parameter value checked before being used?
# III.3 – Class Definition
16 Does each class have an appropriate constructor?
17 Do any subclasses have common members that should be in the superclass?
# III.4 – Data Reference
18 For every array reference: Is each subscript value within the defined bounds?
19 For every object or array reference: Is the value certain to be non-null?
# III.5 – Computation/Numeric
20 Are there any computations with mixed data types?
21 Is overflow or underflow possible during a computation?
22 Are parentheses used to avoid ambiguity?
23 Are divisors tested for zero or noise?
# III.6 – Comparison/Relational
24 For every boolean test: Is the correct condition checked?
25 Are the comparison operators correct?
26 Is each boolean expression correct?
27 Are there improper and unnoticed side-effects of a comparison?
28 Has an "&" inadvertently been interchanged with a "&&" or a "|" for a "||"?
29 Is every three-way branch (less,equal,greater) covered?
# III.7 – Control Flow
30 Will all loops terminate?
31 When there are multiple exits from a loop, is each exit necessary and handled properly?
32 Does each switch statement have a default case?
33 Are missing switch case break statements correct and marked with a comment?
34 Can any nested if statements be converted into a switch statement?
35 Are null bodied control structures correct and marked with braces or comments?
36 Does every method terminate?
37 Are all exceptions handled appropriately?
38 Do named break statements send control to the right place?
# III.8 – Input/Output
39 Have all files been opened before use?
40 Have all files been closed after use?
41 Is buffered data flushed?
42 Are files checked for existence before attempting to access them?
# III.9 – Module Interface
43 Are the number, order, types, and values of parameters in every method call in agreement with the call
44 Do the values in units agree (e.g., inches versus yards)?
# III.10 – Comment
45 Does every method, class, and file have an appropriate header comment?
46 Does every attribute,variable or constant declaration have a comment?
47 Is the underlying behavior of each method and class expressed in plain language?
48 Is the header comment for each method and class consistent with the behavior of the method or class?
49 Are all comments consistent with the code?
50 Do the comments help in understanding the code?
51 Are there enough comments in the code?
52 Are there too many comments in the code?
# III.11 – Storage Usage
53 Are arrays large enough?
# III.12 – Performance
54 Can the cost of recomputing a value be reduced by computing it once and storing the results?
55 Is every result that is computed and stored actually used?
56 Can a computation be moved outside a loop?
57 Are there tests within a loop that do not need to be done?
V – AMBIGUITY OBJECTIVE
# V.1 – Variable and Constant Declaration
58 Are there variables with confusingly similar names?
59 Are all variables properly defined with meaningful, consistent, and clear names?
VI – REDUNDANCE OBJECTIVE
# VI.1 – Variables
60 Are there any redundant or unused variables or attributes?
61 Could any non-local variables be made local?
# VI.2 – Method Definition
62 Are there any uncalled or unneeded methods?
# VI.3 – Performance
63 Can any code be replaced by calls to external reusable objects?
64 Are there any blocks of repeated code that could be condensed into a single method?
in agreement with the called method's declaration?

he method or class?
Project Code: BTree.java
Version of the work product:
Reviewer(s): Nguyễn Hồng Nhân 53-64
Trần Đăng Khoa 16-26
Nguyễn Đình Phúc 27-38
Trần Phương Tĩnh 1-15
Trần Ngọc Yên 39-52

Review date & time:


Work product' size (LoC)
Effort spent on review (man-hour):

Check code Check code Description Line


1 Does the code correctly implement the
2 design?
Does the code implement more than the
3 design?
Is every parameter of every method passing
4 Does every (value
mechanism orreturn
method reference) appropriate?
the correct value
5 at every
Does themethod return point?
code completely implement the
design?
6 Are descriptive variable and constant names 10, 11, 12, 120, 202,
7 used in accord
Is every with
variable namingtyped?
correctly conventions? 270, 1031, 1170,

8 Is every variable properly initialized?


9 Are all for-loop control variables declared in
10 the
Areloop header?
there variables that should be
11 constants?
Are there attributes that should be local
variables?
12 Do all attributes have appropriate access
13 modifiers (private,
Are descriptive protected,
method namespublic)?
used in
accord with naming conventions?
14 Do all methods have appropriate access
15 modifiers (private,parameter
Is every method protected,value
public)?
checked
before being used?
16 Does each class have an appropriate
17 constructor?
Do any subclasses have common members
18 For should
that be inreference:
every array the superclass?
Is each subscript
19 value withinobject
For every the defined
or arraybounds?
reference: Is the
value certain to be non-null?
20 Are there any computations with mixed data
21 types?
Is overflow or underflow possible during a
computation?
22 Are parentheses used to avoid ambiguity?
23 Are divisors tested for zero or noise? 113
24 For every boolean test: Is the correct
25 condition checked? operators correct?
Are the comparison
26 Is each boolean expression correct?
Are there improper and unnoticed side-
27 effects
Has anof"&"
a comparison?
inadvertently been interchanged
28 with a "&&" or a "|" for a "||"?
Is every three-way branch 1095
29 (less,equal,greater) covered?
30 Will
Whenallthere
loopsare
terminate?
multiple exits from a loop, is
31 each exit necessary and handled
Does each switch statement haveproperly?
a default
32 case?
Are missing switch case break statements
33 correct
Can anyand marked
nested with a comment?
if statements be converted 142, 143
34 into
Are anull
switch statement?
bodied control structures correct
35 and marked with braces or comments?
36 Does every method terminate?
37 Are all exceptions
Do named handled appropriately?
break statements send control to
38 the right place?
39 Have all files been opened before use?
40 Have all files been closed after use?
41 Is
Arebuffered data flushed?
files checked for existence before
42 attempting to access them?
agreement with the called method's
43 declaration?
Do the values in units agree (e.g., inches
44 versus yards)?
Does every method, class, and file have an
45 appropriate
Does everyheader comment?or constant
attribute,variable
46 declaration have abehavior
Is the underlying comment?of each method
47 and
classclass expressed
consistent in plain
with the language?
behavior of the
48 method or class?
49 Are all comments
Do the comments consistent with the code?
help in understanding the 693, 735, 785, 831,
50 code? 842,
51 Are there enough comments in the code? 940, 1037, 1227,
52 Are there too many comments in the code? 1332
53 reduced
Are arrays
by large enough?
computing it once and storing the 55,56,57,61,65,67
54 results?
Is every result that is computed and stored 211,213,219
55 actually used?
Can a computation be moved outside a
56 loop?
Are there tests within a loop that do not
57 need to bevariables
Are there done? with confusingly similar
58 names?
Are all variables properly defined with 1170 34.35
59 meaningful,
Are there any redundant or unused variables 1208
consistent, and clear names?
60 or attributes?
Could any non-local variables be made
61 local?
Are there any uncalled or unneeded
62 methods?
Can any code be replaced by calls to
63 external reusable
Are there objects?
any blocks of repeated code that
64 could be condensed into a single method?
Comment Suggestion / Fix ?
Không có design để đánh giá
Không có design để đánh giá
Yes
Yes
Không có design để đánh giá
f, td, tableid, dirtypages (tất cả parameter ở các FILE, TUPLE_DESC, TABLE_ID, dirtyPages,
method),
Không cótuplenum,
design để entrys, pgcateg, nextp, curp
đánh giá tupleNum, entries, pageCategory, nextPage,

Yes
Yes
Các thuộc final hiện tại là ổn
No
Yes
Yes
Yes
Yes
Yes
No, không có subclass
No, không có array reference
Yes
No
Yes
Yes
113: Không kiểm tra BufferPool.getPageSize() Kiểm tra BufferPool.getPageSize() khác 0 trước
trước
Yes khi chia khi chia

Yes
Yes
No
No
Yes
Yes
Yes
Không có break Cần bổ sung comment
No
N/A
Yes
Yes
N/A
Yes
Yes
N/A Thêm dòng if(f.exists()) trước khi thực hiện dòng
No 39, 100, 113, 1038
Yes
N/A
No but acceptable
No
Yes
Yes
Yes
các dòng comment tiếng Trung xen lẫn giữa các
comment tiếng Anh sửa thành tiếng Anh
Yes
Các dòng comment //some code goes here và
các dòng comment đã đề cập không cần thiết xóa bỏ
Yes
55,56,57,61,65,67: BufferPool.getPageSize()
211,213,219: BufferPool.getPageSize() Lưu giá trị vào biến trước để sử dụng
Yes
No
No
34,35: id, pid dễ gây nhầm lẫn
1170: curp Đổi
Đổi id thành
curp bTreePageId
thành currentPage
1208: nextp Đổi nextp thành nextPage
No
Không có biến non-local
No
No
No
Code Review Report
Project Code: GPA-Calculator/Model.java
Version of the work product:
Reviewer(s): Nguyễn Hồng Nhân 53-64
Trần Đăng Khoa 16-26
Nguyễn Đình Phúc 27-38
Trần Phương Tĩnh 1-15
Trần Ngọc Yên 39-52

Review date & time:


Work product' size (LoC)
Effort spent on review (man-hour):

Check code Check code Description Line


1 Does the code correctly implement the
2 design?
Does the code implement more than the
3 design?
Is every parameter of every method passing
4 Does every (value
mechanism orreturn
method reference) appropriate?
the correct value
5 at every
Does themethod return point?
code completely implement the
design?
6 Are descriptive variable and constant names 34
7 used in accord
Is every with
variable namingtyped?
correctly conventions?

8 Is every variable properly initialized?


9 Are all for-loop control variables declared in
10 the
Areloop header?
there variables that should be
11 constants?
Are there attributes that should be local
variables?
12 Do all attributes have appropriate access 20,
13 modifiers (private,
Are descriptive protected,
method namespublic)?
used in 21,
accord with naming conventions?
14 Do all methods have appropriate access
15 modifiers (private,parameter
Is every method protected,value
public)?
checked 153,
before being used?
16 Does each class have an appropriate 172,

17 constructor?
Do any subclasses have common members
18 For should
that be inreference:
every array the superclass?
Is each subscript
19 value withinobject
For every the defined
or arraybounds?
reference: Is the
value certain to be non-null?
20 Are there any computations with mixed data 40.109
21 types?
Is overflow or underflow possible during a 115-116
computation?
22 Are parentheses used to avoid ambiguity?
23 Are divisors tested for zero or noise? 115-116,142
24 For every boolean test: Is the correct
25 condition checked? operators correct?
Are the comparison 163
26 Is each boolean expression correct?
Are there improper and unnoticed side-
27 effects
Has anof"&"
a comparison?
inadvertently been interchanged
28 with a "&&" or a "|" for a "||"?
Is every three-way branch
29 (less,equal,greater) covered? 43-103
30 Will
Whenallthere
loopsare
terminate?
multiple exits from a loop, is
31 each exit necessary and handled
Does each switch statement haveproperly?
a default
32 case?
Are missing switch case break statements
33 correct
Can anyand marked
nested with a comment?
if statements be converted
34 into
Are anull
switch statement?
bodied control structures correct
35 and marked with braces or comments?
36 Does every method terminate? 41
37 Are all exceptions
Do named handled appropriately?
break statements send control to
38 the right place?
39 Have all files been opened before use?
40 Have all files been closed after use?
41 Is
Arebuffered data flushed?
files checked for existence before
42 attempting to access them?
agreement with the called method's
43 declaration?
Do the values in units agree (e.g., inches
44 versus yards)?
Does every method, class, and file have an
45 appropriate
Does everyheader comment?or constant
attribute,variable
46 declaration have abehavior
Is the underlying comment?of each method
47 and
classclass expressed
consistent in plain
with the language?
behavior of the
48 method or class?
49 Are all comments
Do the comments consistent with the code?
help in understanding the
50 code?
51 Are there enough comments in the code?
52 Are there too many comments in the code?
53 reduced
Are arrays
by large enough?
computing it once and storing the 91,96,101
54 results?
Is every result that is computed and stored 163,165
55 actually used?
Can a computation be moved outside a
56 loop?
Are there tests within a loop that do not
57 need to bevariables
Are there done? with confusingly similar
58 names?
Are all variables properly defined with
59 meaningful, consistent,
Are there any redundant and
or clear
unusednames?
variables 27.28
60 or attributes?
Could any non-local variables be made
61 local?
Are there any uncalled or unneeded
62 methods?
Can any code be replaced by calls to
63 external reusable
Are there objects?
any blocks of repeated code that
64 could be condensed into a single method? 145,147,148
Comment
Không có design để đánh giá
Không có design để đánh giá
Yes
Yes
Không có design để đánh giá
variable: GradeScaled
Không có design để đánh giá
Yes
Yes
No, tất cả biến đều có sự thay đổi
No
int numberOfRows = 3;
int
YesnumberOfSemesters = 1;
Yes
listOfCredits,
listOfGrades,
Yes. Vì các attributes đã có giá trị được gán giá trị trước
Không có subclass
Yes.
No
40.numberSemesterHours += classHours; (mixed giữa
int
Yesvà double)
Yes
Các biểu thức chia cho 0 chưa được kiểm tra
Yes
163. Toán tử so sánh bằng sử dụng sai
listOfCredits.get(i).getText()
Yes = null

No
No
Chưa được phủ hết các trường hợp
Yes
N/A
N/A
N/A
No
N/A
Yes
listOfGrades có thể chưa được khởi tạo dẫn đến lỗi khi
thực thi lệnh listOfGrades.get(i);
N/A
Không sử dụng file
Không sử dụng file
N/A
Không sử dụng file
N/A
N/A
Không có comment
Không có comment
Không có comment
Không có comment
Không có comment
Không có comment
No
Không có comment
Yes
91,96,101: pieData[3]+1
163,165: listOfCredits.get(i).getText()
Yes
No
No
No
currGpa
cumGpa
No
Không có biến non-local
No
No
formatter.format(percents[3])+"%"
formatter.format(percents[4])+"%"
Suggestion / Fix ?

gradeScaled

Thêm private vào các thuộc tính này

Check xem listOfCredits có null hay không,


Check xem listOfGrades có null hay không,

Sửa kiểu của classHours thành double

Cần xử lí try catch khi chia cho 0

Sửa "=" thành "=="


Bổ sung lệnh else

Xử lý ngoại lệ bằng cách sử dụng try...catch...

String creditText = listOfCredits.get(i).getText(); ngay dưới


dòng 162

đổi currGpa thành currentGpa


đổi cumGpa thành cumulativeGpa

return formatter.format(percent)+"%";
}
Code Review Report
Project Code: GPA-Calculator/Controller.java
Version of the work product:
Reviewer(s): Nguyễn Hồng Nhân 53-64
Trần Đăng Khoa 16-26
Nguyễn Đình Phúc 27-38
Trần Phương Tĩnh 1-15
Trần Ngọc Yên 39-52

Review date & time:


Work product' size (LoC)
Effort spent on review (man-hour):

Check code Check code Description Line


1 Does the code correctly implement the
2 design?
Does the code implement more than the
3 design?
Is every parameter of every method passing
4 Does every (value
mechanism orreturn
method reference) appropriate?
the correct value
5 at every
Does themethod return point?
code completely implement the
design?
6 Are descriptive variable and constant names 78
7 used in accord
Is every with
variable namingtyped?
correctly conventions?

8 Is every variable properly initialized?


9 Are all for-loop control variables declared in 102
10 the
Areloop header?
there variables that should be
11 constants?
Are there attributes that should be local
variables?
12 Do all attributes have appropriate access
13 modifiers (private,
Are descriptive protected,
method namespublic)?
used in
accord with naming conventions?
14 Do all methods have appropriate access
15 modifiers (private,parameter
Is every method protected,value
public)?
checked
before being used?
16 Does each class have an appropriate
17 constructor?
Do any subclasses have common members
18 For should
that be inreference:
every array the superclass?
Is each subscript
19 value withinobject
For every the defined
or arraybounds?
reference: Is the 90,103,119-125
value certain to be non-null?
20 Are there any computations with mixed data
21 types?
Is overflow or underflow possible during a
computation?
22 Are parentheses used to avoid ambiguity?
23 Are divisors tested for zero or noise?
24 For every boolean test: Is the correct
25 condition checked? operators correct?
Are the comparison
26 Is each boolean expression correct?
Are there improper and unnoticed side-
27 effects
Has anof"&"
a comparison?
inadvertently been interchanged
28 with a "&&" or a "|" for a "||"? 105, 347
Is every three-way branch
29 (less,equal,greater) covered? 341
30 Will
Whenallthere
loopsare
terminate?
multiple exits from a loop, is
31 each exit necessary and handled
Does each switch statement haveproperly?
a default
32 case?
Are missing switch case break statements
33 correct
Can anyand marked
nested with a comment?
if statements be converted
34 into
Are anull
switch statement?
bodied control structures correct
35 and marked with braces or comments?
36 Does every method terminate? 104, 254, 255,
37 Are
Do named break statements send control to 262, 263
all exceptions handled appropriately?
38 the right place?
39 Have all files been opened before use?
40 Have all files been closed after use?
41 Is
Arebuffered data flushed?
files checked for existence before
42 attempting to access them?
agreement with the called method's
43 declaration?
Do the values in units agree (e.g., inches
44 versus yards)?
Does every method, class, and file have an
45 appropriate
Does everyheader comment?or constant
attribute,variable
46 declaration have abehavior
Is the underlying comment?of each method
47 and
classclass expressed
consistent in plain
with the language?
behavior of the
48 method or class?
49 Are all comments
Do the comments consistent with the code?
help in understanding the
50 code?
51 Are there enough comments in the code?
52 Are there too many comments in the code?
53 reduced
Are arrays
by large enough?
computing it once and storing the 341,344,345,34
54 results?
Is every result that is computed and stored 7
55 actually used?
Can a computation be moved outside a
56 loop?
Are there tests within a loop that do not
57 need to bevariables
Are there done? with confusingly similar 233,239,281,28
58 names?
Are all variables properly defined with 7
239,287
59 meaningful, consistent,
Are there any redundant and
or clear
unusednames?
variables 340
32,36,40,42,46,
60 or attributes?
Could any non-local variables be made 50,52,56,66,68
61 local?
Are there any uncalled or unneeded
62 methods?
Can any code be replaced by calls to
63 external reusable
Are there objects?
any blocks of repeated code that 150,318,322,32
64 could be condensed into a single method? 6
Comment
Không có design để đánh giá
Không có design để đánh giá
Yes
Yes
Không có design để đánh giá
final attribute: model
Không có design để đánh giá
Yes
int i = 0;
No
No
Yes
Yes
Yes
Yes
Yes. Hàm khởi tạo mặc định sẽ được gọi
No
No. Không có array
No. Biến model có thể null
No
No
Yes
No.Không có phép chia cho 0
Yes
Yes
Yes
No
Sử dụng |
Trường hợp < chưa được xét đến
Yes
N/A
N/A
N/A
No
N/A
Yes
ra exception vì bị vượt size

N/A
N/A
N/A
N/A
N/A
Yes: các hàm trong Model đều được gọi đúng theo
phần declaration của hàm
N/A
Không có comment
Không có comment
Không có comment
Không có comment
Không có comment
Không có comment
No
Không có comment
Không có array
341,345,347: txt_TextField.getText() và
e.getCharacter()
Yes
No
No
text22
233,239,281,287:
239,287: rows row và rows
340: txt_TextField
Các attributes khai báo ở các dòng này không được
sử dụng trong class, không cần thiết phải khai báo
Không có biến non-local
No
No
150,318,322,326: Lặp lại cách add all item cho
Combobox
Suggestion / Fix ?

MODEL

Di chuyển int i = 0 ở dòng 102 vào phần initialization của for


header ở dòng 103

Kiểm tra null trước khi sử dụng

Thay | bằng ||
Bổ sung lệnh else

String text = txt_TextField.getText();


String character = e.getCharacter(); ngay dưới dòng 340

Đổi
Đổi rows
rows thành
thành index
index
Đổi txt_TextField thành TextFieldElement
Xóa các khai báo ở các dòng này

Tách ra thành một hàm void addAllForCombobox(Combobox


combobox);
Code Review Report
Project Code: GPA-Calculator/Driver.java
Version of the work product:
Reviewer(s): Nguyễn Hồng Nhân 53-64
Trần Đăng Khoa 16-26
Nguyễn Đình Phúc 27-38
Trần Phương Tĩnh 1-15
Trần Ngọc Yên 39-52

Review date & time:


Work product' size (LoC)
Effort spent on review (man-hour):

Check code Check code Description Line Comment


1 Does the code correctly implement the Không có design để đánh
2 design?
Does the code implement more than the giá
Không có design để đánh
3 design?
Is every parameter of every method passing giá
Yes
4 Does every (value
mechanism orreturn
method reference) appropriate?
the correct value Yes
5 at every
Does themethod return point?
code completely implement the Không có design để đánh
design?
6 Are descriptive variable and constant names 15 giá
variable: Root
7 used in accord
Is every with
variable namingtyped?
correctly conventions? Không có design để đánh
8 Is every variable properly initialized? giá
Yes
9 Are all for-loop control variables declared in N/A
10 the
Areloop header?
there variables that should be No
11 constants?
Are there attributes that should be local N/A
variables?
12 Do all attributes have appropriate access N/A
13 modifiers (private,
Are descriptive protected,
method namespublic)?
used in Yes
accord with naming conventions?
14 Do all methods have appropriate access Yes
15 modifiers (private,parameter
Is every method protected,value
public)?
checked Yes, có try catch
before being used?
16 Does each class have an appropriate Yes, hàm khởi tạo mặc
17 constructor?
Do any subclasses have common members định
No sẽ được gọi
18 For should
that be inreference:
every array the superclass?
Is each subscript Không có array
19 value withinobject
For every the defined
or arraybounds?
reference: Is the Yes
value certain to be non-null?
20 Are there any computations with mixed data No
21 types?
Is overflow or underflow possible during a No
computation?
22 Are parentheses used to avoid ambiguity? Yes
23 Are divisors tested for zero or noise? No, không có phép chia
24 For every boolean test: Is the correct cho 0 có câu điều kiện
Không
25 condition checked? operators correct?
Are the comparison Không có câu điều kiện
26 Is each boolean expression correct? Không có câu điều kiện
Are there improper and unnoticed side-
27 effects
Has anof"&"
a comparison?
inadvertently been interchanged N/A
28 with a "&&" or a "|" for a "||"? N/A
Is every three-way branch
29 (less,equal,greater) covered? N/A
30 Will
Whenallthere
loopsare
terminate?
multiple exits from a loop, is N/A
31 each exit necessary and handled
Does each switch statement haveproperly?
a default N/A
32 case?
Are missing switch case break statements N/A
33 correct
Can anyand marked
nested with a comment?
if statements be converted N/A
34 into
Are anull
switch statement?
bodied control structures correct N/A
35 and marked with braces or comments? N/A
36 Does every method terminate? Yes
37 Are all exceptions
Do named handled appropriately?
break statements send control to Yes
38 the right place? N/A
39 Have all files been opened before use? Yes
40 Have all files been closed after use? Yes
41 Is
Arebuffered data flushed?
files checked for existence before N/A
42 attempting to access them?
agreement with the called method's Yes
43 declaration?
Do the values in units agree (e.g., inches N/A
44 versus yards)?
Does every method, class, and file have an N/A
45 appropriate
Does everyheader comment?or constant
attribute,variable Không có comment
46 declaration have abehavior
Is the underlying comment?of each method Không có comment
47 and
classclass expressed
consistent in plain
with the language?
behavior of the Không có comment
48 method or class? Không có comment
49 Are all comments
Do the comments consistent with the code?
help in understanding the Không có comment
50 code? Không có comment
51 Are there enough comments in the code? No
52 Are there too many comments in the code? Không có comment
53 reduced
Are arrays
by large enough?
computing it once and storing the Không có array
54 results?
Is every result that is computed and stored No
55 actually used?
Can a computation be moved outside a Yes
56 loop?
Are there tests within a loop that do not Không có loop
57 need to bevariables
Are there done? with confusingly similar Không có loop
58 names?
Are all variables properly defined with No
59 meaningful, consistent,
Are there any redundant and
or clear
unusednames?
variables Yes
60 or attributes?
Could any non-local variables be made No
61 local?
Are there any uncalled or unneeded Không có biến non-local
62 methods?
Can any code be replaced by calls to No
63 external reusable
Are there objects?
any blocks of repeated code that No
64 could be condensed into a single method? No
Suggestion / Fix ?

root
Code Review Report
Project Code: HotelManSys.java
Version of the work product:
Reviewer(s): Nguyễn Hồng Nhân 53-64
Trần Đăng Khoa 16-26
Nguyễn Đình Phúc 27-38
Trần Phương Tĩnh 1-15
Trần Ngọc Yên 39-52

Review date & time:


Work product' size (LoC)
Effort spent on review (man-hour):

Check code Check code Description Line


1 Does the code correctly implement the
2 design?
Does the code implement more than the
3 design?
Is every parameter of every method passing
4 Does every (value
mechanism orreturn
method reference) appropriate?
the correct value
5 at every
Does themethod return point?
code completely implement the
design?
6 Are descriptive variable and constant names 11, 72, 74, 103, 254, 326, 407,
7 used in accord
Is every with
variable namingtyped?
correctly conventions? 445, 446

8 Is every variable properly initialized? 26, 41, 75, 76, 211, 255
9 Are all for-loop control variables declared in 103, 211
10 the
Areloop header?
there variables that should be
11 constants?
Are there attributes that should be local
variables?
12 Do all attributes have appropriate access
13 modifiers (private,
Are descriptive protected,
method namespublic)?
used in 74, 102, 326
accord with naming conventions?
14 Do all methods have appropriate access
15 modifiers (private,parameter
Is every method protected,value
public)?
checked 254, 326, 407
before being used?
16 Does each class have an appropriate 18-21,44,48-50
17 constructor?
Do any subclasses have common members
18 For should
that be inreference:
every array the superclass?
Is each subscript
19 value withinobject
For every the defined
or arraybounds?
reference: Is the 472,419-425,270,285,299,313
value certain to be non-null?
20 Are there any computations with mixed data 272,287,301,315
21 types?
Is overflow or underflow possible during a 18-21
22 computation?
Are parentheses used to avoid ambiguity?
23 Are divisors tested for zero or noise?
24 For every boolean test: Is the correct
25 condition checked? operators correct?
Are the comparison 109
26 Is each boolean expression correct?
Are there improper and unnoticed side-
27 effects
Has anof"&"
a comparison?
inadvertently been interchanged
28 with a "&&" or a "|" for a "||"? 536
Is every three-way branch 84
29 (less,equal,greater) covered?
30 Will
Whenallthere
loopsare
terminate?
multiple exits from a loop, is
31 each exit necessary and handled
Does each switch statement haveproperly?
a default
32 case?
Are missing switch case break statements 17, 418, 485
33 correct
Can anyand marked
nested with a comment?
if statements be converted 320
34 into
Are anull
switch statement?
bodied control structures correct
35 and marked with braces or comments?
36 Does every method terminate? 361, 367, 368, 379, 385, 386,
37 Are
Do named break statements send control to 397, 419, 421, 423, 425
all exceptions handled appropriately?
38 the right place?
39 Have all files been opened before use?
40 Have all files been closed after use?
41 Is
Arebuffered data flushed?
files checked for existence before
42 attempting to access them?
agreement with the called method's
43 declaration?
Do the values in units agree (e.g., inches
44 versus yards)?
Does every method, class, and file have an
45 appropriate
Does everyheader comment?or constant
attribute,variable
46 declaration have abehavior
Is the underlying comment?of each method
47 and
classclass expressed
consistent in plain
with the language?
behavior of the
48 method or class?
49 Are all comments
Do the comments consistent with the code?
help in understanding the
50 code?
51 Are there enough comments in the code?
52 Are there too many comments in the code?
53 reduced
Are arrays
by large enough?
computing it once and storing the 367,368,379
54 results?
Is every result that is computed and stored 385,386,397
55 actually used?
Can a computation be moved outside a
56 loop?
Are there tests within a loop that do not 273,288,302,316
57 need to bevariables
Are there done? with confusingly similar 408
58 names?
Are all variables properly defined with 478
480
59 meaningful, consistent,
Are there any redundant and
or clear
unusednames?
variables 545
60 or attributes?
Could any non-local variables be made 327
61 local?
Are there any uncalled or unneeded
62 methods?
Can any code be replaced by calls to
63 external reusable
Are there objects?
any blocks of repeated code that 331-345,349-363,367-381,385-
64 could be condensed into a single method? 399
Comment
Không có design để đánh giá
Không có design để đánh giá
Yes
Yes
Không có design để đánh giá
variable: itemno, rn, rtype, hotel_ob, Rn
Không có design để đánh giá
contact, gender, gender2, name, name2, contact2,
int
int j,count=0;
j
No
No
Yes
CustDetails, bookroom, Deallocate
Yes
int rn
No. 18-21: attribute price thiếu this
No 44: attribute name không tồn tại
No
No.
hotel_ob.luxury_doublerrom[rn];hotel_ob.deluxe_doubler
Yes.amount+=obb.price;
Yes, tùy vào giá trị quantity người dùng truyền vào
Yes
No, Không có phép chia cho 0
Yes
No .
hotel_ob.luxury_doublerrom[j]=null
Yes
No
Sử dụng |
Trường hợp >= 3 chưa được bao gồm
Yes
N/A
Chưa có default case
default chưa có break
N/A
N/A
Yes

N/A
Yes
No
N/A
Yes
Yes: các hàm trong Hotel đều được gọi đúng theo phần
declaration của hàm
N/A
Không có comment
Không có comment
Không có comment
Không có comment
Không có comment
Không có comment
No
Không có comment
Yes
367,368,379: hotel_ob.luxury_singleerrom
385,386,397: hotel_ob.deluxe_singleerrom
Yes
273,288,302,316: String format = "%-10s%-10s%-10s
%n";
No
408: Hai biến i,q dễ gây hiểu nhầm với nhau
478:
480: Hai
Khaibiến
báoch,ch2
label làdễ
x gây hiểu nhầm với nhau
545: Khai báo biến t
327: biến j không được sử dụng
Không có biến non-local
No
No
331-345,349-363,367-381,385-399: Lặp lại 1 kiểu tính
toán
Suggestion / Fix ?

itemNo, roomNo, roomType, hotelOb, roomNo

Dòng 26: Trong Singleroom() thêm contact = "", gender = "",


Dòng 41:
Thay vì Trong
khai báoDoubleroom() thêm
int j ở dòng 103 thì gender2
nên khai =báo
"" ở phần
initialization của for header ở dòng 107, 128, 150, 172.

custDetails, bookRoom, deallocate

Check phạm vi của rn trước khi truy xuất mảng


18-21: sửa price thành this.price
44:this.name thành super.name

Cần kiểm tra null trước khi sử dụng


thay kiểu của amout thành float

Sửa thành : hotel_ob.luxury_doublerrom[j]==null

Thay | bằng ||
Có thể dùng thêm lệnh else

Nên bổ sung default case


Nên bổ sung break để tránh nhầm lẫn

Thêm dòng fout.close() sau dòng 455; thêm dòng fin.close() sau
dòng 475

SingleRoom room = hotel_ob.deluxe_singleerrom; ngay dưới dòng


384

Đặt dòng String format = "%-10s%-10s%-10s%n"; ngay dưới dòng


256 và xóa các dòng 273,288,302,316 này

Đổi ch thành functionType, ch2 thành roomType


Đổi x thành whileLoopLabel
Đổi biến t thành thread
Xóa khai báo biến j ở dòng 327

381,385-399:
void deallocateRoom(Singleroom[] roomList);
Project Code: UserDAO.java
Version of the work product:
Reviewer(s): Nguyễn Hồng Nhân 53-64
Trần Đăng Khoa 16-26
Nguyễn Đình Phúc 27-38
Trần Phương Tĩnh 1-15
Trần Ngọc Yên 39-52

Review date & time:


Work product' size (LoC)
Effort spent on review (man-hour):

Check code Check code Description Line


1 Does the code correctly implement the
2 design?
Does the code implement more than the
3 design?
Is every parameter of every method passing
4 Does every (value
mechanism orreturn
method reference) appropriate?
the correct value
5 at every
Does themethod return point?
code completely implement the
design?
6 Are descriptive variable and constant names 195,
7 used in accord
Is every with
variable namingtyped?
correctly conventions? 92

8 Is every variable properly initialized?


9 Are all for-loop control variables declared in 195,
10 the
Areloop header?
there variables that should be 204 194
11 constants?
Are there attributes that should be local
variables?
12 Do all attributes have appropriate access
13 modifiers (private,
Are descriptive protected,
method namespublic)?
used in 134
accord with naming conventions?
14 Do all methods have appropriate access
15 modifiers (private,parameter
Is every method protected,value
public)?
checked 191
before being used?
16 Does each class have an appropriate
17 constructor?
Do any subclasses have common members
18 For should
that be inreference:
every array the superclass?
Is each subscript
19 value withinobject
For every the defined
or arraybounds?
reference: Is the 56,63-
20 Are there any computations with mixed data 65,192,194,1
value certain to be non-null? 67-68
types?
21 Is overflow or underflow possible during a
22 computation?
Are parentheses used to avoid ambiguity?
23 Are divisors tested for zero or noise?
24 For every boolean test: Is the correct
25 condition checked? operators correct?
Are the comparison
26 Is each boolean expression correct?
Are there improper and unnoticed side-
27 effects
Has anof"&"
a comparison?
inadvertently been interchanged
28 with a "&&" or a "|" for a "||"?
Is every three-way branch
29 (less,equal,greater) covered?
30 Will
Whenallthere
loopsare
terminate?
multiple exits from a loop, is
31 each exit necessary and handled
Does each switch statement haveproperly?
a default
32 case?
Are missing switch case break statements
33 correct
Can anyand marked
nested with a comment?
if statements be converted
34 into
Are anull
switch statement?
bodied control structures correct
35 and marked with braces or comments?
36 Does every method terminate?
37 Are all exceptions
Do named handled appropriately?
break statements send control to
38 the right place?
39 Have all files been opened before use?
40 Have all files been closed after use?
41 Is
Arebuffered data flushed?
files checked for existence before
42 attempting to access them?
agreement with the called method's
43 declaration?
Do the values in units agree (e.g., inches
44 versus yards)?
Does every method, class, and file have an
45 appropriate
Does everyheader comment?or constant
attribute,variable
46 declaration have abehavior
Is the underlying comment?of each method
47 and
classclass expressed
consistent in plain
with the language?
behavior of the
48 method or class?
49 Are all comments
Do the comments consistent with the code?
help in understanding the
50 code?
51 Are there enough comments in the code?
52 Are there too many comments in the code?
53 reduced
Are arrays
by large enough?
computing it once and storing the
54 results?
Is every result that is computed and stored
55 actually used?
Can a computation be moved outside a
56 loop?
Are there tests within a loop that do not
57 need to bevariables
Are there done? with confusingly similar
58 names?
Are all variables properly defined with 20,21, 22,
59 meaningful,
Are there any redundant or unused variables 23, 146
consistent, and clear names?
60 or attributes?
Could any non-local variables be made
61 local?
Are there any uncalled or unneeded
62 methods?
Can any code be replaced by calls to
63 external reusable
Are there objects?
any blocks of repeated code that
64 could be condensed into a single method?
Comment
Không có design để đánh giá
Không có design để đánh giá
Yes
Yes
Không có design để đánh giá
variable: COL,
parameter: FullName,
Không có design Location,
để đánh giá Phone, Category,
Yes
int COL = 1;
int
int columnIndex
columnCount == 1;
metaData.getColumnCount();
No
Yes
DeleteUserDAO
Yes
ResultSet rs
Yes
No, không có subclass
No, không có array reference
Các values có thể null
username="user"+ucode
password="user"+ucode
No
Yes
No, không có phép chia cho 0
Yes
Yes
Yes
No
N/A
Yes
Yes
N/A
N/A
N/A
No
N/A
Yes
Yes
N/A
Yes
No
N/A
No
Yes
N/A
Không có comment
Không có comment
Không có comment
Không có comment
Không có comment
Không có comment
No
Không có comment
Không có array
No
Yes
Loop không có tính toán
Loop không có test
No
con, pstmt, stmt, rs chưa rõ ràng; số 1 trong
getQueryResult1 không có ý nghĩa
No
Không có biến non-local
No
No
No
Suggestion / Fix ?

col,
fullname, location, phone, category, username

Di chuyển int COL = 0 ở dòng 195 vào phần initialization của for header ở dòng 197,
Di chuyển
fianl int columnIndex == 1metaData.getColumnCount();
int COLUMN_COUNT ở dòng 204 vào phần initialization của for header ở dòng

deleteUserDAO

Nên check null trước khi dùng ở dòng 192

Xử lý try catch dòng 65: oldUsername.substring(4)


Sửa thành: username="user"+ucode.toString();
password="user"+ucode.toString();
Thêm dòng fis.close() sau dòng 123

Thêm điều kiện if(file.exists()) trước khi thực hiện dòng 115

sửa con -> connection, pstmt -> preparedStatement, stmt -> statement, rs -> result,
getQueryResult1 -> getQueryResult

You might also like