{For beginners} What to do after you found the bug? [Debugging]
Almost every program generates a bug. And someone great said "Debugging is twice the hard as writing the code", so what happens after finding the bug. These two paragraphs explain what to do after finding the bug. Source: not me; When you find the bug, it is usually obvious how to fix it. But not always. Sometimes what seems to be a bug is really an indication that you don’t understand the program, or there is an error in your algorithm. In these cases, you might have to rethink the algorithm, or adjust your mental model. Take some time away from the computer to think, work through test cases by hand, or draw diagrams to represent the computation. After you fix the bug, don’t just start in making new errors. Take a minute to think about what kind of bug it was, why you made the error, how the error manifested itself, and what you could have done to find it faster. Next time you see something similar, you will be able to find the bug more quickly. Or even better, you will learn to avoid that type of bug for good. Hope it helps you in some extent.