15
That time a guy named Mike taught me to read code backwards
I was stuck on a stupid bug for like 2 hours last year in a Discord server for Python learners. This random guy Mike just pops in and says "try reading the code from bottom to top." I thought he was kidding but I tried it and found the issue in maybe 5 minutes. It was a missing closing bracket way down at the end that I kept skipping over. He said he learned that trick from a senior dev back in the 90s when they used printed code on paper. I still do that whenever I'm totally lost on a messy script. Has anyone else tried something like that or got a weird debugging tip from a stranger that actually worked?
2 comments
Log in to join the discussion
Log In2 Comments
thomas_johnson8d ago
My uncle did the same thing when fixing old lawnmower engines. He'd trace the fuel line backwards from the carburetor to the tank to find clogs. Works for code too because your brain stops anticipating what should come next. Same reason you find lost keys better when you retrace steps in reverse order. Kinda like how a mechanic checks spark plugs by going backwards from the distributor. Funny how flipping the direction changes everything.
1
brookep277d ago
Oh man that mechanic fuel line thing is spot on. I was helping my buddy fix his grill last summer and we spent forever trying to figure out why gas was pooling. Finally traced it backwards from the burner and found the valve was stuck halfway. Works the same way with spreadsheets too when you're trying to find where a formula broke.
1