Professional Documents
Culture Documents
3
[1] Slides .............................................................................................................................................................................................................. 3
[1.1] Project Orientation ........................................................................................................................................................................................ 3
[1.2] Introduction to Teamwork.............................................................................................................................................................................. 3
[1.3] Using Processes ............................................................................................................................................................................................. 3
[1.4] Defining a Technical Review Process ............................................................................................................................................................ 3
[1.5] Reviewing the Review Process ....................................................................................................................................................................... 3
[1.6] Technical Review of Code .............................................................................................................................................................................. 3
[1.7] Defining a Configuration Management Process............................................................................................................................................ 3
[1.8] Using Your Configuration Management Processes ....................................................................................................................................... 3
[1.9] Analyzing and Fixing Defects ........................................................................................................................................................................ 3
[1.10] Refactoring ................................................................................................................................................................................................. 3
[1.11] Analyzing & Estimating Requirements ..................................................................................................................................................... 3
[1.12] Testing and Quality .................................................................................................................................................................................... 3
[1.13] Customer Satisfaction ................................................................................................................................................................................ 3
[2] Ian Sommerville. Software engineering update 8th edition. Wesley Computer Publishing 2007. ............................................................... 3
[3] Steve McConnell. Code Complete - Second Edition. ISBN: 1-55615-484-4, 2004 ........................................................................................ 4
[4] Fowler, Beck, Brant-Opdyke, Roberts Refactoring Improving the Design of Existing Code .......................................................................... 4
[5] Wikipedia ....................................................................................................................................................................................................... 4
Nội dung câu hỏi ............................................................................................................................................................................................................ 5
1. Phần trắc nghiệm ............................................................................................................................................................................................... 5
1.1. Introduction to Teamwork ......................................................................................................................................................................... 5
1.2. Using Processes ......................................................................................................................................................................................... 7
1.3. Technical Review ....................................................................................................................................................................................... 9
1.4. Configuration Management ..................................................................................................................................................................... 14
1.5. Testing and Quality .................................................................................................................................................................................. 20
1.6. Analyzing and Fixing Defects .................................................................................................................................................................. 22
1.7. Refactoring ............................................................................................................................................................................................... 24
1.8. Analyzing & Estimating Requirements ................................................................................................................................................... 26
1.9. Customer Satisfaction .............................................................................................................................................................................. 28
2. Phần tự luận ..................................................................................................................................................................................................... 29
2.1. Testing and Quality ...................................................................................................................................................................................... 29
2.2. Refactoring................................................................................................................................................................................................... 38
Danh mục tài liệu tham khảo
[1] Slides
[1.1] Project Orientation
[1.10] Refactoring
[2] Ian Sommerville. Software engineering update 8th edition. Wesley Computer Publishing 2007.
[3] Steve McConnell. Code Complete - Second Edition. ISBN: 1-55615-484-4, 2004
[4] Fowler, Beck, Brant, Roberts Refactoring Improving the Design of Existing Code
[5] Wikipedia
Nội dung câu hỏi
1. Phần trắc nghiệm
1.1. Introduction to Teamwork
Index Question Result CLO SO Level Ref
When you test the number of users access the website at the same
time, that is…
A. Accepting Test
B. Unit Test
C. Integration Test
1 D. Stress Test D CLO.3 K 5 [1.12]
The goal of testing is…
A. To find all defects
B. To admit the software is good enough to release
C. To remove defects
2 D. To find as many defects as they can D CLO.3 K 2 [1.12]
When will you evolve and expand your test suite over time?
A. Whenever a defect is found
B. When adding new features
C. When you look at someone else's code and see a testing hole
3 D. All above D CLO.3 K 4 [1.12]
What is Integration Testing?
A. is a method by which individual units of source code are tested to
determine if they are fit for use
B. is the phase in software testing in which individual software modules
are combined and tested as a group
C. is testing conducted on a complete, integrated system to evaluate the
system's compliance with its specified requirements
D. is a test conducted to determine if the requirements of a
4 specification or contract are met B CLO.3 K 8 [4]
If you want to know how Module1 work together with Module2. What
case of the test will you do?
A. Unit Test
B. System Test
C. Integration Test
5 D. Acceptance Test C CLO.3 K 4 [1.12]
When you test the number of users access the website at the same
time, that is…
A. Accepting Test
B. Unit Test
C. Integration Test
6 D. Stress Test CLO.3 K 2 [1.12]
A. 1, 2, 3, 4
B. 4, 3, 2, 1
C. 2, 1, 3, 4
7 D. 4, 1, 3, 2 C CLO.3 K 9 [1.12]
Which type of project bellow needs more and more testing
A. Medical systems
B. Airplane guidance systems
C. Weapons systems
8 D. All above D CLO.3 K 3 [1.12]
In Agile processes, what phase can customers participate?
A. Unit Test
B. Integration Test
C. Acceptance Test
9 D. System Test C CLO.3 K 4 [1.12]
Which library supports unit test in Eclipse?
A. junit.framework.TestCase
B. java.junit.Test
C. java.junit
10 D. All above A CLO.3 K 7 [1.12]
1.7. Refactoring
Index Question Result CLO SO Level Ref
Which statement is WRONG when you are talking about refactoring?
A. Refactoring does NOT fix defects
B. Refactoring does NOT add new functionality
C. Refactoring does NOT make the codes better
1 D. Refactoring is the technology to improve the code C CLO.3 K 5 [1.10]
2. Phần tự luận
2.1. Testing and Quality
Index Question Solution Example CLO SO Level Ref
1 Write a unit test for that code 1. Test Return value import static CLO.3 K 6 [1.12]
public class Calculator { 2. Test larger max int org.junit.Assert.assertEquals;
public int add(int number1, int type import org.junit.Test;
number2) 3. Test smaller than public class CalculatorTest {
{ min int type Calculator cal = new Calculator();
return number1 + number2; @Test
} public void testAdd1()
} {
assertEquals(3, cal.add(2, 1));
}
@Test
public void testAdd2()
{
assertTrue(cal.add(2000000000,
2000000000) > 2000000000);
}
@Test
public void testAdd3()
{
assertTrue(cal.add(-2000000000, -
2000000000) < -2000000000);
}
}
2 Write a unit test for that code public class CalculatorTest { CLO.3 K 6 [1.12]
public class Calculator { Calculator cal = new Calculator();
public int sub(int number1, int @Test
number2) public void testSub1()
{ {
return number1 - number2; assertEquals(1, cal.sub(2, 1));
} }
}
@Test
public void testSub2()
{
assertTrue(cal.sub(2000000000, -
2000000000) > 2000000000);
}
@Test
public void testSub3()
{
assertTrue(cal.sub(-2000000000,
2000000000) < -2000000000);
}
}
3 Write a unit test for that code 1. Test Return value import static CLO.3 K 7 [1.12]
public class Calculator { 2. Test larger max int org.junit.Assert.assertEquals;
public int mul(int number1, int type import org.junit.Test;
number2) 3. Test smaller than public class CalculatorTest {
{ min int type Calculator cal = new Calculator();
return number1 * number2;
} @Test
} public void testMul1()
{
assertEquals(2, cal.mul(2, 1));
}
@Test
public void testMul2()
{
assertTrue(cal.mul(2000000000, 2)
> 2000000000);
}
@Test
public void testMul3()
{
assertTrue(cal.mul(-2000000000,
2) < -2000000000);
}
}
4 Write a unit test for that code 1. Test Return value import static CLO.3 K 8 [1.12]
public class Calculator { 2. division 0 org.junit.Assert.assertEquals;
public int div(int number1, int import org.junit.Test;
number2) public class CalculatorTest {
{ Calculator cal = new Calculator();
return number1 / number2;
} @Test
} public void testDiv1()
{
assertEquals(2, cal.div(2, 1));
}
@Test
public void testDiv2()
{
cal.div(2, 0);
fails();
}
}
5 Write a unit test for that code 1. Test Many roots public class SolveEquationTest { CLO.3 K 4 [1.12]
public class SolveEquation { 2. Test No root SolveEquation equ = new
public String linearEquation(int 3. Test One root SolveEquation();
number1, int number2)
{ @Test
if(number1==0) public void testLinearEquation1() {
if(number2 == 0) assertEquals("Multi roots",
return "Multi roots"; equ.linearEquation(0, 0));
else }
return "No root";
else @Test
return "One root"; public void testLinearEquation2() {
} assertEquals("No root",
} equ.linearEquation(0, 1));
}
@Test
public void testLinearEquation3() {
assertEquals("One root",
equ.linearEquation(1, 1));
}
}
6 Write a unit test for that code Test first number is import static CLO.3 K 4 [1.12]
public class MaxNumber { max org.junit.Assert.assertEquals;
public int max3(int number1, int Test second number import org.junit.Test;
number2, int number3) { is max public class MaxNumberTest {
if (number1 > number2) Test third number is MaxNumber m = new
if (number1 > number3) max MaxNumber();
return number1; @Test
else public void testMax31() {
return number3; assertEquals(8, m.max3(8, 0 ,4));
else if (number2 > number3) }
return number2;
else @Test
return number3; public void testMax32() {
} assertEquals(7, m.max3(4, 7 ,4));
} }
@Test
public void testMax33() {
assertEquals(9, m.max3(3, 0 ,9));
}
}
7 Write a unit test for that code Test first number is public class MaxNumberTest { CLO.3 K 2 [1.12]
public class MaxNumber { max MaxNumber m = new
public int max2(int number1, int Test second number MaxNumber();
number2) { is max @Test
if (number1 > number2) public void testMax21() {
return number1; assertEquals(8, m.max3(8, 0));
else }
return number2;
} @Test
} public void testMax22() {
assertEquals(7, m.max3(4, 7));
}
}
8 Write a unit test for that codes Test number1 is import static CLO.3 K 6 [1.12]
public class Sort { greater than number org.junit.Assert.assertEquals;
int number1; 2 import org.junit.Test;
int number2; Test number1 is less public class SortTest {
public void sortAsc() than number 2 @Test
{ public void testSortAsc1() {
if(number1> number2) Sort s = new Sort();
{ s.number1= 5;
int temp = number1; s.number2= 3;
number1 = number2; s.sortAsc();
number2 = temp; assertEquals(3, s.number1);
} assertEquals(5, s.number2);
} }
@Test
} public void testSortAsc2() {
Sort s = new Sort();
s.number1= 3;
s.number2= 5;
s.sortAsc();
assertEquals(3, s.number1);
assertEquals(5, s.number2);
}
}
9 Write a unit test for that codes Test number1 is import static CLO.3 K 6 [1.12]
public class Sort { greater than number org.junit.Assert.assertEquals;
int number1; 2 import org.junit.Test;
int number2; Test number1 is less public class SortTest {
public void sortDesc() than number 2 @Test
{ public void testSortDesc1() {
if(number1< number2) Sort s = new Sort();
{ s.number1= 5;
int temp = number1; s.number2= 3;
number1 = number2; s.sortDesc();
number2 = temp; assertEquals(5, s.number1);
} assertEquals(3, s.number2);
} }
@Test
} public void testSortDesc2() {
Sort s = new Sort();
s.number1= 3;
s.number2= 5;
s.sortDesc();
assertEquals(5, s.number1);
assertEquals(3, s.number2);
}
}
10 Write a unit test for that codes Test first number is import static CLO.3 K 5 [1.12]
public class Triangle { max org.junit.Assert.assertEquals;
int number1; Test second number import org.junit.Test;
int number2; is max public class TriangleTest {
int number3; Test third number is Triangle m = new Triangle();
public int maxLength() max @Test
{ public void testMmaxLength1() {
if(number1 >= number2) assertEquals(8, m.max3(8, 0 ,4));
if(number1 > number3) }
return number1;
else return number3; @Test
if(number2 > number3) public void testMmaxLength2() {
return number2; assertEquals(7, m.max3(4, 7 ,4));
else return number3; }
}
} @Test
public void testMmaxLength3() {
assertEquals(9, m.max3(3, 0 ,9));
}
}
2.2. Refactoring
Index Question Solution Example CLO SO Ref
1 Refactoring that codes 1. Naming: r, Area, //Create date: 3/5/18 CLO.3 K 3 [4]
public class circle { Perimeter //Create by: SanhTK
double r; 2. set a constant public class R_Circle {
variable for 3.14 private static final double PI =
public double Area() { value 3.14;
return r * r * 3.14; 3. Comment for class double radius;
}
public double area() {
public double Primeter() { return radius * radius * PI;
return 2 * 3.14 * r; }
}
} public double primeter() {
return 2 * 3.14 * radius;
}
}
2 Refactoring that codes 1. Naming: print //Create date: 3/5/18 CLO.3 K 4 [4]
public class print { 2. duplicte code //Create by: SanhTK
public void printStart() { printStart and public class Print {
printEnd public void printAll(String
System.out.println("************* 3. Comment for class content) {
****");
System.out.println("***********
System.out.println("******START** ******");
****");
System.out.println("************* System.out.println("******"+cont
****"); ent+"******");
}
public void printEnd() { System.out.println("***********
******");
System.out.println("************* }
****"); }
System.out.println("*******END**
*****");
System.out.println("*************
****");
}
3 refactor paintResult becomes the 1. Naming: paint public class Paint { CLO.3 K 9 [4]
method with 2 parameters 2. many parameters //print the result in location(x,y)
public class paint { 3. Comment for class and the color(red blue,green)
//print the result in location(x,y) public void paintResult(Location
with the color(red blue,green) point
public void paintResult(int x, int y , Color color){
, byte red, byte blue, byte green){ //do not need to rewrite this
//do not need to rewrite this code code
} }
} }
class Location{
int x;
int y;
}
class Color{
byte red;
byte blue;
byte green;
}
4 Refactoring that codes 1. Naming: //Create date: 3/5/18 CLO.3 K 6 [4]
public class maxNumber { maxNumber //Create by: SanhTK
public int max2(int a, int b) { 2. duplicate code public class MaxNumber {
if (a >= b) max2 and max3 public int max2(int number1, int
return a; 3. Comment for class number2) {
else if (number1 >= number2)
return b; return number1;
} else
public int max3(int a, int b, int c) { return number2;
if (a >= b) }
if (a >= c)
return a; public int max3(int number1, int
else number2, int number3) {
return c; return max2(max2(number1,
else if (b >= c) number2),number3);
return b; }
else }
return c;
}
}
5 Remove duplicate codes 1. comment //Create date: 3/5/18 CLO.3 2 [4]
class Employee 2. move method to //Create by: SanhTK
{ parent class Employee
public string Name { get; set; } {
public string ID { get; set; } public string Name { get; set; }
} public string ID { get; set; }
public void DoWork() { ... }
class Coder extends Employee }
{
public void DoWork() { ... } class Coder extends Employee
} {
}
class Manager extends Employee
{ class Manager extends Employee
public void DoWork() { ... } {
} }
6 Refactoring that codes 1. Naming: q, b, c //Create date: 3/5/18 CLO.3 K 7 [4]
public class Sort { 2. duplicate code //Create by: SanhTK
int a; 3. Comment for class public class Sort {
int b; int number1;
int c; int number2;
public void ascSort(){ int number3;
if(a>b) public void ascSort(){
{ compare2Number(number1,
int temp =a; number1 =number2);
a = b; compare2Number(number1,
b = temp; number1=number3);
} compare2Number(number2,
if(a>c) number2=number3);
{ }
int temp =a; private void compare2Number(int
a = c; n1, int n2) {
c = temp; if(n1>n2)
} {
if(b>c) int temp =n1;
{ n1 = n2;
int temp =b; n2 = temp;
b = c; }
c = temp; }
} }
}
}
7 Refactoring that codes 1. Naming: a, b, c //Create date: 3/5/18 CLO.3 K 7 [4]
public class Sort { 2. duplicate code //Create by: SanhTK
int a; 3. Comment for class public class Sort {
int b; int number1;
int c; int number2;
public void descSort(){ int number3;
if(a<b) public void descSort(){
{ compare2Number(number1,
int temp =a; numbber1=number2);
a = b; compare2Number(number1,
b = temp; number1=number3);
} compare2Number(number2,
if(a<c) number2=number3);
{ }
int temp =a; private void compare2Number(int
a = c; n1, int n2) {
c = temp; if(n1<n2)
} {
if(b<c) int temp =n1;
{ n1 = n2;
int temp =b; n2 = temp;
b = c; }
c = temp; }
} }
}
}
8 Refactoring that codes 1. Naming: Bonus, //Create date: 3/5/18 CLO.3 K 4 [4]
public class Employee { Name //Create by: SanhTK
String Name; 2. set constant public class Employee {
double Bonus; variable for 1400000 private static final int basicRate =
double payRate; value 1400000;
3. Comment for class String name;
public double basicSalary(){ double bonus;
return payRate*1400000; double payRate;
}
public double salary(){ public double basicSalary(){
return Bonus + basicSalary(); return payRate*basicRate;
} }
} public double salary(){
return bonus + basicSalary();
}
}
9 Refactoring that codes 1. Naming: //Create date: 3/5/18 CLO.3 K 3 [4]
public class Equation { LinearEquation, //Create by: SanhTK
public String LinearEquation(int a, QuadraticEquation public class Equation {
int b){ 2. duplicate code public String linearEquation(int a,
if(a==0) 3. Comment for class int b){
if(b==0) return "any number"; if(a==0)
else return "no number"; if(b==0) return "any number";
else return "one number"; else return "no number";
} else return "one number";
}
public String QuadraticEquation(int
a, int b, int c){ public String
if(a==0){ quadraticEquation(int a, int b, int
if(b==0) c){
if(c==0)return "any number"; if(a==0){
else return "no number"; linearEquation(b, c);
else return "one number"; }else{
}else{ int delta = b*b - 4*a*c;
int delta = b*b - 4*a*c; if(delta < 0) return "no number";
if(delta < 0) return "no number"; else if(delta == 0) return "one
else if(delta == 0) return "one number";
number"; else return "two numbers";
else return "two numbers"; }
} }
}
10 Refactoring that codes 1. remove method class StudentInfo{ CLO.3 K 6 [4]
public class Student { has many parameters int id;
2. Comment for class String name;
public void display(int id, String int classID;
name, int classID, String birthday, String birthday;
String address, String phone) String address;
{ String phone;
System.out.println(id + ", " + name + }
", "+ classID + ", " + birthday + ", "+
address + ", " + phone); //Create date: 3/5/18
} //Create by: SanhTK
}
public class Student {