But the distinction between bad/inexperienced programmers and skillful/experienced programmers starts here. A lot of the “programmers” out there would consider their problem for (maximum) 5-ten minutes, then go to StackOverflow/FXP/Their senior programmer friend, and post something similar to that:
Hello. My code doesn’t work. Here it is: some code Please fix it to me. If you can’t spot at the very least 3 wrong aspects of this post, well, you should start thinking about a brand new career. This post shows an average “I actually have never really made an effort to solve this problem, solve it to me” method of thinking. You are able to immediately see that:
“My code doesn’t work” – Well, OK there. If it worked, you wouldn’t have posted it here, right? What really doesn’t work? Would you expect your friends to understand your code independently? “Please correct it for me” – This shows zero will to truly solve the problem. You need to realize that provided that the issue is yours, you are the one who should solve it. And naturally, I must mention that asking others/your smarter/more knowledgeable friend ought to be the Very last thing you do. First, you might try and solve the situation alone.
So that we saw just what a newcomer would do. Now, how would Fantasy fiction handle this annoying but frequent situation? First, before we are able to solve the bug, we must see the bug. If the exception is raised, well, you can easily tell the positioning of the bug. Otherwise (discussing logical bugs):
If you deal with a good IDE, like Visual Studio, Eclipse, PyCharm, etc., you are able to run this system step-by-step, examine your variables’ content, and find the line/function that fails to run properly. Or even, it is possible to print checkpoints to see where code reaches before it breaks, and you can print your variables’ values to find out what goes wrong. Obviously, the very first approach is preferred as it’s easier and more convenient way of working.
After spotting where the bug occurs, you should start looking for why it can. Usually, you’ll locate a problematic worth of among the variables on the line of the bug (could be a never raised flag, a never incrementing counter, a null or falsy value, etc.). If the thing is not variable related, it might be an uninitialized object, unopened connection, or other arlkkg you may forget to do – import a library, reset a link, etc.
Now, what’s left is to trace the problematic variable’s value, see where it’s assigned wrongly, and try to fix it (or at a minimum get the cause to the problematic assignment). Should you don’t know why a specific function fails to function as you’d expect it to, just what a specific class does, or what a weird error means, remember that GOOGLE is your best friend. Googling your issue fails to cause you to an unsatisfactory programmer. It actually makes you a much better one – a programmer that may find his needed information by himself.
Now, you ought to remember. Debugging is not really a science, it’s an art. It doesn’t possess a clear step-by-step solution. Begin debugging “open minded” – bugs occur because of strange reasons, in unexpected places. Also, understand that there is certainly no problem in asking for health – never feel embarrassed to ask your friends/a programming forum/StackOverflow for answers. But also keep in mind that other people may well be more ready to accept help if you suggest to them which you a minimum of tried to cope with your problems. Don’t allow them to feel that they do your job.
Lastly, a great programmer that uses the methods described here, Google and friends in a wise and balanced way would find and fix his problems thousands of times faster than a programmer that every bug he sees equals to a different call his experienced friend receives. So in a single sentence: Do your very best to analyze it utilizing the tools you might have, and get others as long as really needed.