Monday, October 19, 2009

My Madeup Midterm Questions!

1. What is an anti-pattern? Give one example of an anti-pattern.

"An antipattern is a recurring negative solution to a problem" (http://www.ibm.com/developerworks/opensource/library/os-junit/#N100C5) In otherwords, an anti-pattern is a test where it seems like it is testing a lot of the code, but rather it has missed much of the code. It is giving a false sense of security that the code is working properly.
Examples of anti-patterns:
Happy path tests - Tests if everything is working properly and gives the correct results. This is only an anti-pattern if this is the only type of test used.
Validation and boundary tests - Like the happy path test, but tests the boundaries of something(maybe a method, list, input, etc.) and also tests if the correct output is thrown if there is invalid input. This could be an anti-pattern if the data that you put in returns valid when it should not be valid. For example, if an input should be out-of-bounds, but it still returns valid input.
Easy tests - Tests that are very simple (like testing toString()) because the code is hard to test. These tests work but do not accomplish much.
Overly complex tests - A test that is so complex you cannot tell if it is correct or not. The anti-pattern is not knowing if a test is correct or not. It is better to have a simple test that you know is correct.

2. When overriding equals(), you must also override hashCode(). Why could overriding hashCode() in the following manner not be good?

public int hashCode() { return 0; }

This is because the hash would become one long list of values in one bin.


3. What makes a build tool, like ANT, so useful?

-Build tools are cross-platform
-It allows for the compilation and testing of code to be automated
-It can download and install everything that is needed for running the code
-It can be incorporated with IDE's like Eclipse.

4. What is the main problem with only allowing one person to checkout and modify a project at a time?

Everyone would have to wait on that one person.

5. What is the difference between White Box testing and Black Box testing?

In Black Box testing, there is no knowledge of the internal structure of the program. Some examples of Black box testing is equivalence and boundary value analysis. In White Box testing, a person could test the paths within a program. Some examples of White Box testing is control flow testing, data flow testing, and branch testing.

6. In the article about coverage tools, In pursuit of code quality: Don't be fooled by the coverage report, what did the author mean by "fools gold?"

It is when there is a high coverage report, but it doesn't mean that the code was exercised well.

7. What does the following code written in an ant build file
<Property Name="checkstyle.config.file" value="checkstyle.xml" />
do?


It defines a property, checkstyle.config.file, and sets its value to checkstyle.xml.


8. According to the Stanford article, why are heavy multitaskers unable to perform better in the tests than the light multitaskers?

The heavy multitaskers were unable to filter out the excess information and thus were not able to concentrate.

9. Emma's coverage report indicates that you have covered 100% of you code. Does this mean that your code is now bug free? If not, explain.

Even though all of your code has been executed by Emma, it doesn't necessarily mean that your code is bug free. A test could cover all of the lines of code but not have been fully exercised. For example, a person could write a single test that covers every line of the code.


10. What irritates hackers the most when they are trying to help people on forums?

When people ask questions that they could have easily looked up the answer to themselves.

0 comments:

Post a Comment