Debugging and Testing
Debugging and testing are topics which are not usually the focus of university teaching.
We highly recommend The Practice of Programming by Kernighan and
Pike, which teaches much more than just writing code. Specifically, it covers testing,
debugging, portability, performance, and design alternatives.
- What was your last bug? What was your hardest bug?
- How would you debug a distributed program?
- A program works sometimes and fails other times - why?
- A program works sometimes and fails other times on the exact same input - why?
- How would you determine where a program spends most of its time?
- How does JUnit make the process of testing easier?
- List five ways in which C code can be non-portable. What can you do to make the code portable?
- Write tests for implementation of an isupper() function.
- Should you test private methods? Should you test one line methods?
- If you find and fix an error by adding debug code, should you remove the debug code afterwards? Should you leave them in with a conditional compilation flag or with a run time flag?
- What is a buffer overflow and how can hackers exploit it?
- How can you use Valgrind to solve segfault problems?
- How does Valgrind catch access uninitialized memory?