1 of 7

CS Pathways

Unit 3-Module 5

Debugging-Walkthrough

2 of 7

Unit 3 Module 5

Learning How to Debug Programs-Code.org

  • Debugging is a skill and an art. With practice you learn how to write relatively bug-free code and more importantly you learn about yourself and the kinds of errors you typically make.

  • But learning how to debug takes some time and getting used to, and you will learn about the different kinds of things that can go wrong when you write programs.

3 of 7

Debugging is part of the problem-solving process of programming.

  • Rarely does code work exactly the way you want the first time.

  • If you write some code and need to work out a few bugs that does not mean you are bad programmer - actually the opposite might be true.

  • Debugging a creative and continuous cycle of writing, testing, and improving code.

4 of 7

5 of 7

Common Types of Errors I

Programming errors generally fall in two categories:

#1 Syntax errors

  • Things you misspelled or wrote in such a way the computer doesn't understand what you're trying to say
  • Typically there will be an error message of some kind that is a clue about what it can't understand
  • Fix these with careful reading of the lines that have errors

6 of 7

Common Types of Errors II

#2 Logic errors

  • The program runs but doesn't do what you think it should.
  • Can be tricky to fix because there might not be an error message
  • Fix by retracing your steps, being humble, and trying to understand why the computer is interpreting what you wrote the way it is.

7 of 7