Skip to main content

Subsection 7.1.1 Part 1: Where Do Bugs Come From?

Activity 7.1.1. Whose Bugs Are These?

Think back over the programming you have done, in any language.
Bugs in C programs come from a short list of slips, and the same few account for most of the time we will spend debugging in this course:
Some of these will be caught by the compiler. The ones that are not caught are the dangerous ones: they compile cleanly and then run incorrectly.
A few habits prevent a large part of that list before it happens: plan the design on paper before typing; write in small chunks and test each one before moving on; give every function one clear job; use named constants instead of magic numbers; and keep the code readable, with descriptive names. The full checklist, with the reasoning behind each item, is in Subsectionย 7.2.2.

Activity 7.1.2. Which Habit Would Have Caught It?

Pick one error from your list.