News for hackers. Stuff that matters.
Re:Ask HN: Why I failed interview by fixing bug without usin... by davelnewton on Wednesday May 04, 2016 @10:58AM (#11628788)
How is this question answerable with the information given? How do we even know that's why you "failed" the interview?
Re:Ask HN: Why I failed interview by fixing bug without usin... by eugenis on Wednesday May 04, 2016 @12:32PM (#11629516)
I was given the reason explicitly that I failed because I didn't use debugger to fix the bug.
Re:Ask HN: Why I failed interview by fixing bug without usin... by codegeek on Wednesday May 04, 2016 @12:35PM (#11629530)
ok then explain to us how you did fix the bug without a debugger ?
Re:Ask HN: Why I failed interview by fixing bug without usin... by Grishnakh on Wednesday May 04, 2016 @02:27PM (#11630496)
He solved it by inspection. It's the best way to fix a bug: it requires understanding the code (which you should anyway), and is fast and easy. Using a debugger requires a lot of overhead: recompiling with debugging symbols enabled, starting up the debugger, isolating where in the code the error happens, stepping through the code line-by-line around that point, etc. It's a pain in the ass. If you can skip all that and just look at the code and see "oh, this is obviously causing the problem", fix it and test it, that's a far superior method.

Of course, solving bugs by inspection isn't always viable. At some point, it takes less time to go through the overhead of using the debugger, because it lets you step line-by-line and lets you inspect memory etc., then just staring at the code. If you're highly competent, you know when each approach is the best choice.

It sounds like this stupid company came up with an idiotic example case of a trivial bug to use as an interview exercise, and then rules out people who don't go through the unnecessary step of using the debugger when the bug is obvious to a competent coder just by looking at it.

If they're testing for the ability to use a debugger, they should just come out and say so: "you can probably spot the bug here just by looking at the code, but we're looking for someone who can use a debugger for solving much harder bugs, so please take that approach here and show us how you'd go about finding a bug using a debugger."

Re:Ask HN: Why I failed interview by fixing bug without usin... by eugenis on Wednesday May 04, 2016 @12:43PM (#11629588)
I read the code just like reading an English article and then I saw the bug and fixed it right on spot. Then ran successfully. No print statements were added. Existing codes were not changed at all. To give an example, one of the bug is for (int i = 0; i <= len; i++) It is obvious so I just change <= to <.