I’ve got a CRAZY question for you…
How much of your coding time is spent debugging?
I’ll bet A LOT.
And how much of that time do you spend learning debugging techniques? I’ll bet not all that much.
Debugging is frustrating and often feels like a complete waste of time. Some days you probably spend more time debugging your Gemset than actually writing a line of code! We’ve all been there.
I’ve got 4 eye-opening tips I want to share that will help you push through the hard times.
1. DIV counting. (1:48)
The most common reason that text/images are missing is that you have an uneven number of HTML tags. Specifically DIV tags.
DIV counting is a method using Sublime Text’s “find & replace” functionality to see if you are missing any DIVS by counting all the opening + closing HTML elements.
2. Stackoverflow & Commenting (2:33)
Stackoverflow.com is your best friend. Use a combination of Google + Stackoverflow to find as many possible solutions as you can.
Once you’ve diagnosed the problem: don’t be afraid to use Commenting to temporarily bypass unrelated errors.
3. Guessing (9:18)
Use your intuition, and don’t be afraid to just make a handful of educated guesses!
If your first guess didn’t work? Great! Try again… and keep trying.
4. Narrowing (12:25)
Narrowing helps you find the error in your project by placing temporary flags (ie. simple tests) before and after suspected trouble spots. If you can trigger the first flag, but not the second, it’s most likely you’ve found the error.
You’ll want to watch the video above to see my examples for using each of these methods.
Remember that debugging is a natural part of programming, so don’t be demoralized when your computer shows you a litany of errors like a scene out of The Matrix.
I encourage new developers to brute force as many of these methods as possible.
The definition of insanity? “To keep doing the same thing over and over but expecting different results.” So instead, learn from this blog post. Experiment! Learn from your experiment. And move onward! (rinse and repeat)