Sample final 2

advertisement
CS321
Dr. Kinga Dobolyi
Section 001
Final Examination
Student Name: ____________________________________________________
Student G#: ______________________________________________________
Student signature for Honor Code:
________________________________________________________
Part 1: Short Answer. DO NOT REPEAT the question in the answer for full credit. LIST means
used a bulleted list – writing in a paragraph will not receive full credit.
1. What is a design principle? What is a design pattern? Do not give examples of either, instead
explain what each one is in ONE SENTENCE. (4 pts)
2. List 5 code smells and in ONE SENTENCE (or less) explain what each one is. (10 points)
3. Are the following metrics good or bad? Circle the correct answer, and explain, in ONE SENTENCE
(or less) each one. (8 points)
a. LOC (lines of code)
GOOD
BAD
b. Cyclomatic complexity of a method
GOOD
BAD
c. Defects discovered per man-hour
GOOD
BAD
d. Earned value per LOC
GOOD
BAD
4. LIST five distinct risks that you could encounter in every software project (5 points)
5. Calculate the cyclomatic complexity of the following code (show your work for partial credit – 6
points):
public void tryThis(ArrayList list){
for (int i = 0; i < list.size(); i++){
if (list.get(0).toString().equals("NULL")){
if(i == 11)
System.out.println("hi");
System.out.println("hello");
System.out.println("yes");
}else if(i == 2)
System.out.println("ok");
else
System.out.println("no");
}
}
6. List five distinct things that we have discussed in class that correlate with defects in source code.
Explain the correlation in ONE SENTENCE (or less) for each item (10 points)
7. What is verification? What is validation?(4 points)
8. With respect to software testing, what is observability? What is controllability? Give an example
of each IN ONE SENTENCE (6 points)
Observability is:
Example of Observability:
Controlability is:
Example of controllability:
9. Given the following method, create a MINIMUM SIZED test suite for the method, where each
test case is a call to the method with different input parameters, that achieves three different
types of coverage (see below). Then, identify which of your tests locates the fault (on line 3),
and explain how that fault turns into an error, and finally a failure, using the line numbers below
(13 points).
1
public String calculate(int x, int y, String name){
2
String substring = null;
3
if (x > 0){
//FAULT: should be >= 0
4
if (y < name.length())
5
substring = name.substring(x,y);
6
else
7
return "too long";
8
}
9
if(x == y)
10
return "NULL";
11
12
13
return “substring is” + substring;
14 }
Test cases that result in full STATEMENT coverage (number them):
Test cases that result in full EDGE coverage (refer to previous numbers when necessary, don’t
re-write them):
Test cases that result in full PATH coverage (refer to previous numbers when necessary, don’t
re-write them):
10. In the previous question, write two Junit tests for the method. You do not need to write the
entire test class: just write the test methods themselves and assume the rest of the test class is
written (document any assumptions that you need). You should cover both a VALID and an
INVALID input. Your tests should also be WHITE BOX. (8 points)
11. What is the critical path? What Is slack, with respect to the critical path? (4 points)
12. What is static verification? What is dynamic verification? (explain each in at most ONE
SENTENCE). Then give ONE EXAMPLE of each. (8 points)
Static verification is:
Example of static verification:
Dynamic verification is:
Example of dynamic verification:
Part 2: Diagramming
13. Consider the following specification
The login module has a Customer, Authentication, and Database classes. The Customer
sends their username and password to the Authentication object, which queries the
Database. The Database tells the Authentication object if the username and password
matches. Based on this information, the Authentication object returns either a
confirmation page to the user, or an error page. At any point during this interaction, the
Authentication object can make a request of the Database to write a log entry in one of
its tables.
a. Write a sequence diagram for the scenario above (10 points)
b. Write a state diagram for the scenario above (10 points)
c. Write a class diagram for this scenario. You MUST include return types for all methods,
and types for all variables/parameters. (12 points).
Specification recopied below for your convenience:
The login module has a Customer, Authentication, and Database classes. The Customer
sends their username and password to the Authentication object, which queries the
Database. The Database tells the Authentication object if the username and password
matches. Based on this information, the Authentication class returns either a
confirmation page to the user, or an error page. At any point during this interaction, the
Authentication class an make a request of the Database to write a log entry in one of its
tables.
Part 3: True/False
14. Circle TRUE or FALSE for the following statements, and defend your choice in ONE SENTENCE.
(32 points)
a. A project that is on schedule has an earned-value to planned-value ratio of 0.
TRUE FALSE
b. A risk with a 10/10 impact is a constraint
TRUE FALSE
c. We expect Defect Removal Efficiency to be highest during the testing phase.
TRUE FALSE
d. We can prove software does not have defects
TRUE FALSE
e. All project metrics should be actionable
TRUE FALSE
f. If our test suite has 100% code coverage, we have found all faults
TRUE FALSE
g. The process model used for your semester projects was an agile model.
TRUE FALSE
h. A prescriptive project model cannot be an incremental model
TRUE FALSE
i.
A software error is visible to the user
TRUE FALSE
j.
XP uses User Stories.
TRUE FALSE
k. Mutation testing directly uncovers faults in your source code.
TRUE FALSE
l.
Non-functional requirements cannot be tested.
TRUE FALSE
m. A state diagram should have at least one transition between states without a
trigger.
TRUE FALSE
n. CRC cards are used to create a class diagram.
TRUE FALSE
o. We want high coupling between classes and low cohesion inside of them.
TRUE FALSE
p. I write my name on all exams.
TRUE FALSE
Download