It's always okay to not know, but it's never okay to give up on learning. Gain skills to navigate debugging with confidence even when you are still learning.
How to Not Know the Right Answer
In Computer Science, lots of answers can be correct. As students learn more and more skills, you will learn that there are more and more ways to solve problems, and sometimes all can be considered correct. When analyzing code, ask:
- Did it run as expected? If you wrote a program to add 2 + 2 and it gave you 4, it’s probably working right!
- Are we using lesson skills? If students just learned about while loops but don’t use them in the next problem, they may have a right answer, but not the most useful right answer.
- If something went wrong, what’s the error?
A Simple Debugging Protocol
As teachers, we may often feel that we need to be the keeper of all knowledge in order to earn our place in front of the classroom. Yet in Computer Science, a field that is ever changing and evolving, that's an impossible ask for even the most talented software developer. Instead of focusing on having all the answers, we can shift our mindset to to focusing on how we can best facilitate learning and teaching important skills like using available resources.
In this simple debugging protocol, the teacher does very little instructing; the main role is to ask questions that will guide students towards the answer, possibly with the teacher learning along with them.
1. Ask the student what they are seeing go wrong.
- Is the code not running as expected? If the code runs, but 2 + 2 is giving you 22 instead of 4, this is an indication that there is a logic issue or missed step somewhere that can be reevaluated. The computer is doing exactly what it's been told to do, the instructions just did not do as the programmer intended.
- Are there errors, and if so, what are they? This indicates that the code is not written in a way the computer can understand. Our guide to debugging can be helpful at identifying exactly what might be wrong.
2. Ask the student what they think the error code might mean OR why they think it may not be running as expected.
- If it's not running as expected, ask:
- Where do we see the line of code that is making this happen?
- Where should [x] occur in your code? What's there instead?
- If it's an error, ask:
- What line number is in the error, and what does the console say is wrong?
- Encourage students to look back at their resources: why is this problem different than the last?
3. If they're not sure, Google it together!
- Say: "Hm, that's an interesting one. Let's look that up to double check that we know what to look for."
- Stay with the student a they Google so you can parse sources and answers with them. This is where as a teacher, you can help students make sense of what they're seeing, even if you are learning it along with them. You can collaborate to figure it out together!
4. Look at the code but avoiding touching the computer.
- It can be SO tempting to grab a computer and add that missing colon, but let students learn from themselves.
- Give specific directions. Say things like "I see something on line 5 that looks suspicious." Ask students to utilize shoulder partners for fresh eyes if they don't see the mistake.
- Student really struggling? Walk them through corrections verbally. "Put your cursor between the p and the quotation mark on line 7 and..."
5. Ask students after they solve: what was the mistake? How can we make sure that next time we make a new, better mistake?
- If you're using an error scoreboard in class, give it a tally - you did good work and learned from something that went wrong, and that should always be celebrated!