Debugging and Documentation

Part of: Creative Development

Debugging Debugging is the process of finding and correcting errors. Once you know a bug exists, debugging locates it and fixes it. Common techniques include: - Adding print statements to inspect values while the program runs. - Testing with inputs whose correct output you already know. - Checking boundary cases like empty input or the largest allowed value. - Reading error messages carefully to find the failing line. Guarding against bad input prevents many crashes. For example, computing an average must avoid dividing by zero when the input is empty: Reading an empty line and the length check both guard against a runtime error, turning it into a sensible result. Program Documentation Throughout development, teams write program documentation : comments and notes that explain what the code does and why . Documentation helps collaborators understand the code and helps the original author remember decisions later. Good comments explain intent, not the obvious: Documentation must be kept up to date : a comment that no longer matches the code is worse than no comment, because it misleads readers. Why It Matters Debugging and documentation work together. Clear documentation makes bugs e

Challenge: Safe Average