3 ms·
I generally use the debugger to test my hypothesis. This is something that too many people overlook when debugging. My debugging goes like this: 1) I need to
by bsder 5y ago
I generally use the debugger to test my hypothesis. This is something that too many people overlook when debugging.
My debugging goes like this:
1) I need to have a model in my head of what I think is going on even if simple.
2) I make a change X with the idea that result Y should happen. VERIFYING THIS HYPOTHESIS IS VITALLY IMPORTANT. Your change should create cause and effect.
3) I test that result Y actually happened--generally this is where I'm using the debugger.
4a) If result Y happened and result Y means my program is fixed, congratulations, you are done.
4b) If result Y happened but my program is not yet fixed, go back to make another hypothesis and go back to step 2.
4c) If result Y did not happen, undo change X, update your mental model and go back to step 1. This is where the "think hard" part mostly comes in.
The toughest bugs are the ones that require you to update your mental model the most.