Debugging
1.[3p] Put the steps of the debugging method in order.
Put the steps of the debugging method in order.
Cut the failing case down until only what is needed to fail remains
Make the bug happen on demand, with a written input and expected output
Make the observation and keep or discard the hypothesis
State a hypothesis specific enough to predict an observation
Show the answer
b, a, d, c
2.[3p] A bug lies somewhere in a 1000 line region. How many checks does binary search need, at most, to reach a single line?
A bug lies somewhere in a 1000 line region. How many checks does binary search need, at most, to reach a single line?
3.[2p] A test passed at a release 512 commits ago and fails now. How many builds does git bisect need in the worst case?
A test passed at a release 512 commits ago and fails now. How many builds does git bisect need in the worst case?
4.[3p] Why is "something is wrong with the sorting" a useless hypothesis?
Why is "something is wrong with the sorting" a useless hypothesis?
The answer is: It predicts no observation, so nothing you look at can confirm or kill it
The answer is: It predicts no observation, so nothing you look at can confirm or kill it
The answer is: It predicts no observation, so nothing you look at can confirm or kill it
5.[3p] A bug appears only sometimes, on the same input. What does intermittency usually mean?
A bug appears only sometimes, on the same input. What does intermittency usually mean?
The answer is: The program depends on something other than its input: time, randomness, ordering, or state left over from a previous run
The answer is: The program depends on something other than its input: time, randomness, ordering, or state left over from a previous run
The answer is: The program depends on something other than its input: time, randomness, ordering, or state left over from a previous run
6.[2p] Logging an object in a browser console logs a live reference, so expanding it later can show a state the object did not have when it was logged.
Logging an object in a browser console logs a live reference, so expanding it later can show a state the object did not have when it was logged.
The answer is: True
7.[3p] Which of these make a print statement more useful?
Which of these make a print statement more useful?
Select all that apply
The answer is: Printing typeof beside the value when the type is in question, Labelling the print so the line it came from is obvious, Printing at the boundaries between functions
8.[3p] Where should an assertion be placed while hunting a bug?
Where should an assertion be placed while hunting a bug?
The answer is: On the invariant that would have to break for the bug to occur
The answer is: On the invariant that would have to break for the bug to occur
The answer is: On the invariant that would have to break for the bug to occur
9.[2p] Before git bisect can be trusted, one thing must exist: a single command that answers good or bad reliably. What is that called, in one word?
Before git bisect can be trusted, one thing must exist: a single command that answers good or bad reliably. What is that called, in one word?