Debugging
To debug your code efficiently, you need to understand what each line in your code does
After a jam-packed 12 days of learning, today felt a little more relaxed. I did not make a new project nor did I learn a new concept. Instead today was about debugging. One of the most essential part of coding, where not only do you need to find your mistake but also try to fix it to get your code doing what you actually want it to do.
I learned a structured way to debug:
- Describe the problem clearly (sometimes just writing it out helps).
- Reproduce the bug consistently so you know what triggers it.
- Go through each line manually to see what’s actually happening vs. what you think is happening.
- Watch for red underlines or syntax hints, often the IDE is already trying to tell you what’s wrong even before you press Run.
- Print statements are your best friend, use them generously across your code which will show you the values your code is really working with.
- And if all of this still does not help, use a debugger to step through code line by line.
After this, I worked on a few small exercises to intentionally break my code and then fix it. For example, I wrote a simple loop that was supposed to stop at 10 but kept running forever because I forgot to update the counter inside the loop. Added a print statement which quickly showed me the variable wasn’t updating. Once I fixed that, the code behaved as expected.
My biggest takeaway today: debugging is not just about fixing errors, it’s about understanding your code more deeply. Every bug is basically your code teaching you how it really works. Instead of being frustrated, I’m starting to see bugs as little puzzles.
Now that the bugs are squashed, time to smash some gym reps. After that, I plan to have a lovely dinner prepped by the wife before unwinding in bed with my book. Currently reading: Night Angel Nemesis by Brent Weeks.
Until tomorrow!