0

How to recognize when there is a bug in program or you have an inability to solve concrete problem? I noticed when I concentrate too much time on a problem and can't find a solution, I am starting to be so subjective and can't recognize one of those two states. How far to go with a search for solutions, and not kill your will, but just say "That's it, I did everything I could, this is a bug, I can't do anything more about it, but just report it."

I am looking for your advices to learn to deal with this problem, or a recipe for this to be less painfull and exhausting to programmers? How to learn when to stop and what is enough?

2

I highly recommend working with other programmers if you are hitting a roadblock. Often the conversation goes something like this:

[you] I'm stuck on this bug, I can't seem to figure out what's happening

[other] What's the issue?

[you] yada yada yada

[other] what have you tried and what have you figured out so far?

[you] blah blah blah, this that and the other...

[you] oh...

[you] thanks!

[other] any time

If not that, often a more senior person can help you narrow down your approach or sometimes mention some little-known or unintuitive facts about the relevant context.

Another crucial piece is to divide and conquer. You need eliminate possibilities or you will end up going in circles. That goes hand-in-hand with testing your assumptions. When you get into a situation where you can't figure out why something is happening, it's likely that something you believe is true is not true. Start testing all the things that you think are obviously true.

Be wary of debuggers. They can be helpful for novice developers but can end up consuming a lot of your time. Also, they are mostly useless for timing issues such as multi-threading problems. I once had a (very smart) colleague who completely disagreed with me and insisted on using debuggers. Once he had an issue that he couldn't figure out. I asked him to run it without the debugger. He did and the problem disappeared.

1

Most bugs you can solve by inspection, but this relies on your experience and skill.

BUT! if you have a hard bug or complex code, you don't need to do it the 'quick' way. You simply add more and more tests, debug statements, logging etc until you find out exactly what line of code, or what situation the bug is caused by. If your requirements are detailed enough a computer could find the bugs.

Most times when I see someone stumped by a problem, they have skipped basic steps and made assumptions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy