DEV Community

Discussion on: What do you do when you encounter a hard to fix bug?

Collapse
 
thomasthespacefox profile image
Thomas Leathers • Edited

a few tricks:
One trick is to read through your code as if you were explaining it. Try to explain what each line of code is supposed to do, and what each section of code does. when the code stops making sense, look into that bit of code more closely... think of it as sort-of teaching yourself to code/ how your program works, in the third person. The important thing is to read the code.

Another trick that sometimes works for me is to look at variables at various stages of a process. for example if you are getting a strange result, try looking at each stage of that process that leads to that result, and try to find something that seems out of place.

Finally a great way to fix a stubborn bug is to have others look over your code. This is especially true if you are new to programming, but it never hurts to ask for a second opinion.