O
10

Just realized trace tables are way easier than I thought they'd be

I was stuck on a nested for loop for like two hours last Sunday, the kind where you change two variables and the output jumps around. My friend who works as a QA tester said just write a trace table, pencil and paper style, with columns for each variable. I thought it was old school nonsense but gave it a shot. Turns out watching the values change row by row makes the logic click, it's like seeing the code breathe instead of just reading it. I tried it on a bubble sort example from a free course on freeCodeCamp and finally understood why the inner loop runs n-1 times. Now I'm using trace tables for every practice problem, even small ones. Has anyone else found a low tech trick that beats debugging tools for certain bugs?
1 comments

Log in to join the discussion

Log In
1 Comment
ryanh56
ryanh5614d ago
Seeing the code breathe instead of just reading it" hit the nail on the head. My buddy once spent a whole night chasing a bug in a loop, then tried a trace table and found the mistake in like ten minutes because the column for the counter showed it resetting early.
6