3.5. Fixing Errors in Your Code¶
As you progress through this class, you will find yourself having to fix problems in your code. Whether the code simply won’t run or is giving you the wrong answer, fixing problems with code is a vital part of being a programmer. The process of working through issues in code is called debugging. We will cover debugging in depth in a later chapter, but here is what we need to know now.
- Errors are common and even the most experienced programmers are regularly debugging their code.
- Asking for help from peers and mentors can be a key part of the process.
- Google is very much an acceptable resource when it comes to debugging.
3.5.1. Asking for Help¶
Before asking for help, make sure that you have the answers to some of the questions that may be asked of you and that your
questions to the person who is helping you are detailed.
“My code doesn’t work” or “Why doesn’t my code work?” are difficult questions for someone to answer.
“I tried using
Console.WriteLine() like the chapter outlined, but the screen says ‘Invalid Input’.
What does that mean and how might I go about addressing it?” is a good question to ask.
Here are some tips on what information you might need when asking for help:
- Ask Google for help first. If you see an error message as opposed to “Hello World!”, copy it into Google and search. You may find the answer right away! If you don’t find the answer or are not sure you understand it, make note of that.
- Make sure to document everything. The steps you took before you encountered the problem, screenshots of what the error message is, what your application should be able to do. This is all helpful information for the person assisting you.
- When asking your question, make sure that the person knows what documentation you have. If you took a screenshot or saved Google results related to the error message, inform the person who is helping you before you all start working together on the issue.
When trying to fix an error in code, many people start by following the exact same steps to see if they get the same results. The more information you can give the person who is helping you, the easier it will be for them to help you.
These tips also apply to whenever you encounter a technical issue. Having screenshots and a recorded set of steps that you took before encountering the issue can help tech support figure out how to correct the problem and assist you!