You have all met this scenario. I am using a new algorithm for the first time, and I am sitting at my computer trying to find out if it is some syntax problem or if I have misunderstood the algorithm. In a scenario like this, I would sooner rewrite the program than spend time staring at the screen. But this raises the general question, that I am curious to hear from programmers more experienced than myself:
How do you judge when it is the right time to rewrite, or should you continue sitting there staring at your code looking for the bug?
Are there any useful heuristics that professional programmers use?
This doesn’t sound right to me at all. As long as you don’t understand the (required) algorithm you should not write code. That’s called trial and error and is a pretty sure way to end up with poor and buggy code. Think before you act.
As food for thought a bit provocative statement: