Codesters FAQ is the official FAQ site for codesters.com. We will continue to update this blog with the most common questions we receive form teachers using Codesters.

Debugging

In programming, debugging involves locating and correcting errors in a computer program. Debugging is an integral part of coding whether you write 5 lines of code or 5000. Knowing how to debug is an important skill to master as you learn to code.

Types of Errors:

  • Syntax Errors: A character or string incorrectly placed in a command or instruction that causes the program not to run.  This also includes missing lines of code in loops, conditionals, and functions. 

  • Logic Errors: A logic error produces unintended or undesired results and  may not immediately be recognized as an error.  Finding logic errors can involve walking through the code and for example, checking the value of variables and how they are evaluated.  

Debugging Strategies:

  • Use the debugging guide on the student reference card
  • Comment out sections of code to try to isolate the error
    • # turns everything that comes after on the same line into a comment. 
      A comment is a line in a program that doesn't execute. It is usually used to document a section of code. 
  • Use a "Say" or "Print" tool to see what is stored in a variable. Sometimes an "if" statement fails because the value is not what was expected.  Remember that case matters. 
  • If the  error line number is greater than the last line number in the program, it means that there is an error in the body of the program. Checking conditionals, loops and functions is a good place to start