Why would failure ever be a good thing? Well, in computer programming, failure can mean that you have done a good job testing your code and you have found a bug. Finding a bug during testing means that you can fix your bug before you submit your project or assignment to your boss or your teacher. In the process of fixing the bug, you might realize how to improve other parts of the code as well. Without thorough testing, with a possible failure or two along the way, you cannot be confident that your code will do what it is supposed to do.
So, how do you go about testing? One way is to think of as many examples of possible input data as you can. Good input, bad input, simple input, and complicated input should all be tried. Keep a list or a file of the examples so that you can try your code on the examples each time you change your code. Another way is to enlist the help of co-workers or friends to try to "break" your code. You can never completely predict what the end users of your code will do, so it is good to get others involved in testing your code to mimic the eventual end users. Having others use your code can point out not only bugs for you to fix but user interface improvements that you can make as well.
A little bit of failure can go a long way. One seemingly insignificant bug could lead you to make a series of improvements to your code. By stepping back from programming and focusing on testing instead, you can use failures to your advantage to guide you to write even better code. Don't be afraid of failure. It can be a good thing!