How to Introduce Debugging to Kids

When you are learning to program or teaching kids to program, there can seem to be too many steps from idea to a working program. If you are a computer scientist, you’ve already contextualized what you need to think about - idea, logic, design, program, testing and debugging. To a beginner, however, debugging seems to be a huge hurdle. However, you already have all the tools you need to make sense of programming and debugging. At AgentSheets, Inc. we’ve always worked to make programming understandable to non-programmers. If you can solve a problem, you can program and you can debug.

What is the Debugging Process?

Debugging is simply the process of testing and fixing computer code. There are, in a basic sense, two types of errors encountered in programming. First, you can have a syntactic error. This is an error with the usage of the language of the program. For example, a forgotten semicolon or parentheses in a text-based language. In AgentCubes online, there is a Visual Programming Language. By making the pieces of the program into visual components that can be dragged and dropped and manipulated to create a program, it’s not easy to make a syntactic mistake. Each piece of the programming language visually indicates the pieces of information that it needs to complete it. For example, to specify that a player can control a character in a game using the cursor, you just need to specify the keys to press and any other conditions for movement (such as moving on a road or path). Then, the action part of the rule tells the character to move when the right key has been pressed.

The other kind of programming error is semantic, or errors of meaning. Put simply, these are errors in logic. They can be simple or complex - sometimes the solution doesn’t fit the problem, but you might not realize it until the solution is partially programmed. This happens to us in everyday life, too. We may start preparing a recipe and realize we are missing an ingredient and have to make a similar recipe that uses something that we do have instead. This is similar to programming. We may be telling a computer to take an action or compute a value, but not giving it the proper data at the right time so that it can complete the action correctly. Or, we may have forgotten to complete a step to actually get the proper data. When this happens, we have to fix the problem, whether we are cooking or programming.

What are the 5 steps of Debugging?

Once you’ve noticed that there is an error in a program, there are about five steps to correcting it, and it’s very similar to correcting a problem we may encounter in our lives as well:

1. Identify

First, we need to identify the problem. Where is the flaw in our logic? What parts of the program are affected? What exactly is not working? In a computer program this may mean we are not getting a correct result, a piece of the program may not be doing its job for some reason, or a character may not be responding at the appropriate time. It’s important to understand what the error is.

2. Analyze

Second, we dig deeper. Now that we know what is going wrong, we need to understand why it is going wrong. We may need to put some code in place to help us make sure we can see when it is going wrong; what might be missing or incorrect, etc. For example, suppose we test the movement of a character of a game and realize that it does not move left if the left cursor key is pressed. We need to know if that’s because there is a missing instruction telling the character to move when the cursor key is pressed or if there is another reason the character is not moving. It could be that a rule is specifying the incorrect key and needs to be changed to the left cursor key.

3. Identify a solution and plan to implement it

Third, we identify possible solutions to the problem. If a rule is missing, we need to program that rule. If an existing rule is incorrect, it needs to be corrected. When we understand why the program isn’t working, solutions start to become easier to identify. In complex programs, we might find that data is missing, a test for the data is incorrect, or data is not getting updated at the proper times.

4. Implement the solution

Fourth, we implement our fix. We have taken the steps to elaborate the problem, locate what parts of the program are affected, and how to solve the problem. We take so much care to identify and locate the problem because we do not want to add errors when we are correcting our code. Having as much information about a problem and its location in the program helps to avoid this.

5. Re-evaluate

Finally, we re-test our program to verify that our fix has worked, our code is working properly, and we have not introduced any further problems. We just repeat these steps until we have the program doing what we want it to do.

The Debugging Tools in AgentCubes

As you can see, these five steps are similar to how we fix literally anything in our lives that isn’t working. Identify the problem, understand the problem, identify a solution, put that solution into practice and then re-evaluate. Of course, in programming, just like in life, planning ahead can save you from having many problems to debug. In AgentCubes online, there are many tools to help you discover the code that isn’t quite working properly and help you fix it. We provide visual programming by drag and drop - our Visual AgenTalk (VAT) language to minimize or eliminate syntactic errors. We have patented Conversational Programming to help with semantic errors.

Planning your programming logic is always recommended - that helps minimize logic errors. However, sometimes we may only partially understand a problem and need to go ahead and start programming. When we teach programming, we teach Computational Thinking Patterns, which are logic patterns that outline the algorithms for things that we often need to program. VAT includes elements for many of these. Of course, imagination knows no limits, so why should a programming language? Original ideas require tools to help programmers work out the logic through trial and error.

Conversational Programming is a patented and subtle way for AgentCubes online to help you see your logic at work while you are programming. The software can evaluate your program as you are creating it, and give you some hints about how it will run. Rules that you create will turn red if the conditions are false or green if the conditions are true. As you run a program, you can iteratively see exactly what parts are working and what parts are not because they are red or green. As you build your program, you can catch errors happening and correct them. Instead of the old program-run-debug cycle, you can have a conversation as you build each piece of your program, knowing that it is working before adding additional pieces. The information is subtle enough to be there just when you need it and is not intrusive.

Whether your program is simple or complex, debugging doesn’t have to be. Just like you can have conversations with your friends as you navigate life, you can have a conversation with the computer while you are programming. It can help you build skills and confidence more quickly and have fun while you are watching your ideas come to life.