I'm a beginner developer—is this debugging normal?
I've been stuck on the same bug all day and can't find the cause. I keep staring at the code and it seems logically correct, but the values come out weird.
For those of you who are good at debugging, could I ask how you break down your approach? I'm desperate, so this is my first time posting here.
4 answers
Agreed, we all go through that as beginners. If you're using Python, just go for print debugging.
I did the same when I was a junior. Instead of staring at the code, it's better to follow the data flow. Add logs along the way to see where the values start going wrong, and try to reproduce it with a small input if possible. It might feel like a waste of time, but it's actually the fastest path in the end.
It works fine, but hmm... what you think is logically correct is probably just your own illusion. I'd recommend setting a breakpoint in the debugger and stepping through it line by line. Or get a code review from the person next to you.
Oh, I didn't know that... I just asked GPT lol