But the difference between bad/inexperienced programmers and skillful/experienced programmers starts here. The majority of the “programmers” on the market would consider their problem for (maximum) 5-10 minutes, then go to StackOverflow/FXP/Their senior programmer friend, and post something similar to that:
Hello. My code doesn’t work. Here you go: some code Please fix it to me. In the event you can’t spot at least 3 wrong reasons for this post, well, you should begin considering a new career. This post shows a normal “I actually have never really made an effort to solve this problem, solve it for me” method of thinking. You are able to immediately observe that:
“My code doesn’t work” – Well, OK there. If this worked, you wouldn’t have posted it here, right? What really doesn’t work? Would you expect your friends to understand your code by themselves? “Please fix it to me” – This shows zero will to really solve the situation. You have to realize that as long as the problem is yours, you are the person who should solve it. And of course, I must mention that asking other people/your smarter/more skillful friend needs to be the Very last thing one does. First, you are trying and solve the issue on your own.
So that we saw just what a newcomer would do. Now, how would Fantasy fiction handle this annoying but frequent situation? First, before we can solve the bug, we need to spot the bug. If the exception is raised, well, it is possible to tell the location of the bug. Otherwise (discussing logical bugs):
If you deal with a great IDE, like Visual Studio, Eclipse, PyCharm, etc., it is possible to run this system step-by-step, look at your variables’ content, and find the line/function that fails to perform properly. Otherwise, you are able to print checkpoints to view in which the code reaches before it breaks, and you may print your variables’ values to see what fails. Obviously, the initial approach is preferred as it’s easier and much more convenient means of working.
After spotting in which the bug occurs, you should start trying to find why it does. Usually, you’ll look for a problematic price of one of many variables on the type of the bug (could be a never raised flag, a never incrementing counter, a null or falsy value, etc.). If the issue is not variable related, it could be an uninitialized object, unopened connection, or any other arlkkg you may forget to accomplish – import a library, reset a connection, etc.
Now, what’s left is to trace the problematic variable’s value, see where it’s assigned wrongly, and try to remedy it (or at a minimum get the cause to the problematic assignment). If you don’t know why a particular function fails to work as you’d expect it to, exactly what a specific class does, or what a weird error means, always remember that GOOGLE is your best friend. Googling your trouble fails to make you an unsatisfactory programmer. It genuinely makes you a better one – a programmer that will find his needed information by himself.
Now, you should remember. Debugging will not be a science, it’s an art. It doesn’t possess a clear step-by-step solution. Always start debugging “open minded” – bugs occur due to strange reasons, in unexpected places. Also, understand that there exists no problem in seeking health – never feel embarrassed to ask your pals/a programming forum/StackOverflow for answers. But additionally remember that others may well be more available to help in the event you show them that you at the very least tried to cope with your problems. Don’t permit them to believe that they do your job.
And finally, an excellent programmer that uses the methods described here, Google and friends in a wise and balanced way would find and repair his problems a thousand times faster when compared to a programmer that each bug he sees equals to a different call his experienced friend receives. So in just one sentence: Do your best to research it utilizing the tools you have, and inquire others only if really needed.