Live data from Hacker News

Ask HN: How to reduce sloppy mistakes?

news.ycombinator.com

1–10 of 40 posts

Ask HN: How to reduce sloppy mistakes?

#1
Hi,

I make a ton of sloppy mistakes when I code. Stuff that leaves me kicking myself when I spend 20 minutes trying to debug it. Even though I've gotten better at programming, the number of sloppy mistakes I make is still way too high and its my biggest time drain.

I think part of the problem comes from writing code, glancing through it quickly, and then testing it with a large number of "F5s". I'm trying to get away from this and am reading my code more thoroughly before testing to see if it works. Anyone struggle with the same issues? HOw did you improve?

Thanks!

Re: Ask HN: How to reduce sloppy mistakes?

#7
Write tests before you code, and spend more time planning software with pen and paper before you actually write it. If you're having doubts about your abilities or solutions and work as part of a team, ping team members or friends.

Re: Ask HN: How to reduce sloppy mistakes?

#8
Don't use a debugger - think when something doesn't work. The feedback you get by thinking about your own code teaches you much faster than anything you get with compile/run/debug cycle.

"I think that without a debugger, you don't get into that mindset where you know how it behaves, and then you fix it from there. " http://linuxmafia.com/faq/Kernel/linus-im-a-bastard-speech.h...

Re: Ask HN: How to reduce sloppy mistakes?

#9
I carefully read my patches before I commit them. Probably sounds pretty obvious, but I find that I can catch most problems by simply running "git diff" and then carefully and slowly reading through the output.

This is especially true when I'm editing existing code rather than checking in new functionality. I read the diff while mentally asking myself "is this going to change anything other than what I intended it to change".

Post reply on HN