There appears to have been no effort to debug the code
Debugging code is one of the most important things that a developer can do. When a program’s result is unexpected, or when a program crashes at runtime, debugging is a way for a developer to quickly isolate and identify the problem. In the vast majority of cases, once the problem is identified, the solution is clear. But when a developer does not debug their code, the problem becomes much harder to fix.
Why this is a problem
Without making the effort to debug failing code, the less obvious the problem is, the harder it will be to find a solution. Sometimes you are lucky and the problem may be evident in the code itself. But that is not always the case. A fix that might take ten minutes to find through debugging may drag out for hours and consume the effort of multiple people.
Why this is worth a downvote
Without debugging, you risk wasting the time of those who are trying to help you. If the problem is easy to fix, and would have become self evident when debugging, there was no need to ask the question in the first place. Time you spent composing the question could have been spent fixing your problem. Time others spent reading your question could have been spent helping others with harder to diagnose problems. And when your problem is hard, without isolating the issue through debugging, it requires others to guess at the possible causes. There will be much more back-and-forth over possible causes and solutions, taking much more time than was necessary to fix your problem. Debugging helps prevent all of this.
What to do next
Debug your code! Execute your code with your favorite IDE’s debugger attached. Place breakpoints near where your code fails. Examine variables and their contents at runtime. Watch your logic evaluate these variables and examine the results for correctness. You may find what you believed to be the result was not, allowing you to fix your algorithm. Or you may not understand why the algorithm was failing. Record all of this information–the algorithm, your variable’s values, and what the unexpected result was. You will need it to compose a good question!
Once you have debugged your code, take everything that you have learned and edit your question. Note: don’t add this information as one or more comments on your question! Add all your findings in a clear and well-formatted edit. Add missing code, if any, that is relevant to the question.
If you found the solution to your problem when debugging, and that solution may be useful to others, you can add an answer to your question with details about what you did and what you found while debugging. If other people answered your question, and they were somewhat or exactly right, select the best one as correct. If your answer is the only one, after the required waiting period, you can select your answer as correct and close out the question. It may seem odd, but that’s how we handle this situation. If your answer is of no use to anyone else, and no one has answered your question, you can simply delete it.
How to debug
Often times new developers do not know how to debug their code. Following are a number of different articles detailing how to debug code using different tools.
What is debugging
If you aren’t sure what this whole “debugging” thing is, here’s an introductory article on Wikipedia.
Visual Studio and Visual Studio Code
To learn how to use debugging tools in the latest version of Visual Studio, click this link. For Visual Studio Code, look here.
You can learn how to debug in the Xcode IDE at this link.
To learn how to debug your Android app in Android Studio, visit this link.
C and C++ using the Gnu Debugger (GDB)
For a tutorial using the Gnu Debugger to debug your C or C++ application, visit this link.
Your favorite IDE
Have a favorite IDE/Language combo you want to add to this list? Submit your addition here!
Leave a comment!
Once you have done this, leave a comment to the person who sent you this link. They will be happy to retract their downvote.
Did this page help you?
This website is here for everyone’s benefit, most importantly yours! If this did not help you, or if you would like to leave feedback, please create an Issue regarding this page on GitHub, or submit an improvement directly.