Week 7

Overview

Give yourself a HUGE pat on the back, you made it to the final week of the course. We will be wrapping up the two programming projects from last week. We will also be exploring how to “debug” a program. I am hoping that the debugging discussion will be timely because many of you will be struggling with some bugs in your final assignments. These debugging techniques will help!

Objectives

By the end of this week, students should be able to:

Activities & Assignments

Lesson

Debugging

How to Avoid Debugging

  1. Start Small This is probably the single biggest piece of advice for programmers at every level. Of course, it’s tempting to sit down and crank out an entire program at once. But, when the program – inevitably – does not work then you have a myriad of options for things that might be wrong. Where to start? Where to look first? How to figure out what went wrong? I’ll get to that in the next section. So, start with something really small. Maybe just two lines and then make sure that runs ok. Hitting the run button is quick and easy, and gives you immediate feedback about whether what you have just done is ok or not. Another immediate benefit of having something small working is that you have something to turn in. Turning in a small, incomplete program, is almost always better than nothing.
  2. Keep it working Once you have a small part of your program working the next step is to figure out something small to add to it. If you keep adding small pieces of the program one at a time, it is much easier to figure out what went wrong, as it is most likely that the problem is going to be in the new code you have just added. Less new code means its easier to figure out where the problem is.