Hacker News new | ask | show | jobs
Ask HN: Why I failed interview by fixing bug without using debugger?
12 points by eugenis 3699 days ago
11 comments

Not really anywhere near enough information to answer the question as it is stated, but in order to provide you with an answer, it could come down to how you identified and/or fixed the bug.

Did you put a bunch of print statements all over the place or really, any at all? Did you comment out some lines of code and repeatedly run the sample? Did you make changes of any kind and repeatedly run the sample to understand what was happening?

If you answered Yes to any of the above, then you went about it the hard way. You could have introduced additional errors into the code in a non-trivial case. You could have left debugging/print statements in places they shouldn't be. There are probably other good reasons why you shouldn't do it this way.

By the way this is how Rob Pike says you should debug. He is not a fan of debuggers.

FWIW. I am a fan of debuggers. But reading and understanding the code, like the asker says he did, is best!

I always ask debug questions in when I interview candidates, because it's a skill way too many devs simply don't have. in that situation i'd tell them what you thought was the issue and why, then proceed to prove it through the debugger.

Yes it's tedious, and in real life you fix it and move on, but not all bugs are that simple, and it's an interview so the aim of the game is to demonstrate your ability as a well-rounded developer.

I used debugger during the first few years of coding. Then I learned the idea of coding without using debugger. I tried it. It was unnatural at first. But I wanted to see if it is really good or not. Without realizing it, I have done with the last 5 years writing a lot of codes day and night without using debugger. I wrote C, ObjC, Go, Java, C#, JavaScript, PHP. I can write code as soon as I wake up all the way until the moment I need to sleep again. I can read code as natural as I read an English essay. Sure there are some very badly written codes that is hard to understand, as there are badly written English articles too. I fixed trivial bugs (such as edge cases or typo) by reading it, more difficult one by enabling debug logs (much more productive in long run), there are separate tools for memory leak inspection, a hanged process can be inspected by process dump log.
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 <.

Wow. OK. What makes you think this was the exact specific reason? Were there maybe other bugs you did not catch? Maybe there were less obvious things in the code that could have been fixed/changed? Is there any possibility of other factors?

I think the answer as to why this happened is in you. You just have to ask the right questions of yourself and answer honestly. Do some honest root cause analysis.

And then at the end of the day, there are those times where you do incredibly well and all seems as it should be and you don't get an offer. If there is absolutely nothing to learn from the experience, well then shrug and move on.

Seems like not a good place to work at, if they didn't even design a proper problem that needs debugger to be solved. And expected you to use debugger.
How is this question answerable with the information given? How do we even know that's why you "failed" the interview?
I was given the reason explicitly that I failed because I didn't use debugger to fix the bug.
ok then explain to us how you did fix the bug without a debugger ?
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."

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 <.
Just look at it as they self selected as not a good place to work.
You're lucky, seriously. Imagine you've used the debugger - you'd had to work with such persons/company.
Without knowing much detail all I can guess is that the 'test' was not about fixing the bug, but about testing your methodology.

This sounds like when high school students get marked down/fail for "not showing their working" in maths classes.

It doesn't matter that they can "do it in their head" the teacher is testing to see if they actually understand how to solve the problem, not if they can get the right answer.

Yeah, I've never liked tests like that; they're insulting to intelligent people. It's like having a driving test at the DMV where they ask you to list all the steps in driving to a store nearby, and then they fail you because you missed a bunch of steps such as "open the car door", "close the car door", "put feet on pedals", "check adjustment of rearview mirrors", etc. It reminds me of an old 80's Twilight Zone episode where some teenagers find a leprechaun and one wishes that his parents would do whatever he wanted, and then his parents can't do the simplest things because he has to tell them every single little step to take, such as having to take the frozen pizza out of the box before putting it in the oven.

If your test requires the test-taker to show every minute, trivial step, then your test is a failure.

My point was that maybe their test wasn't what it appears to be. The bug could have been anything - the test may have been to see if applicants are comfortable using a debugger.
Yes, I'm sure it was exactly that. My point is that it's a failure, because it's an insult to the test-taker's intelligence. "Here's a trivial problem to solve, now I want to see you solve it in the most inefficient manner possible."
No. Interview failed you. Apply better job. Using Debugger easy. Using brains not easy.
The obvious answer? You didn't demonstrate that you can use it.
Because they want developers who develop like their current employees.
not enough information, but one of the possibilities is they're trying to judge how you approach problems. You solved the bug great, but without using the debugger did you explain how you came to the solution? If they can't tell, there's no way for them to tell whether you just got lucky or if you actually have the skills to solve different problems
Interviewer - Use the debugger to find the bug.

You - No.

Interviewer - I guess you don't know how to use the debugger and it is required for the job. Have a nice day.

I guess that the interviewer needs to in a put in a bit more effort to present a problem that warrants using a debugger. Who debugs a hello world program?
fixing bugs is not a skill. Being able to look pro is, and it requires doing the some arcane black magic to make customers think they are not being scamed. You failed in black arts. That's all.