Development Process,
Errors & Testing
The iterative cycle of building software, the four types of errors that break programs, how to test systematically, and what counts as input and output.
- Program development is iterative: you cycle through stages and findings send you back to earlier stages — not a straight line.
- Incremental means adding new functionality one feature at a time; each increment grows the program.
- Iterative means revisiting and improving something that already exists based on what you've learned since.
- A syntax error violates the rules of the language, so the program won't run at all.
- A logic error runs but produces the wrong result because the logic is flawed.
- A runtime error runs but crashes partway through due to an illegal operation.
- An overflow error happens when a calculation's result is too large for the number of bits used.
- Good tests use typical, extreme, boundary, and invalid inputs; boundary and extreme cases are where most bugs hide.
- An input is any data a program receives, including events like clicks, taps, and key presses — not just typed text.
- Write documentation throughout development, not saved for the end, to clarify thinking and ease collaboration.
§1 The Development Cycle
Program development is iterative: you cycle through stages, and findings in one stage often send you back to revisit earlier stages. There is no straight line from idea to finished program.
The exam loves the word "iterative." When a question asks about the development process, the answer that mentions revisiting earlier stages or repeating the cycle is almost always correct.
§2 Iterative vs. Incremental Development
Two related but distinct ideas describe how programs get built over time:
- Incremental means building up in pieces — you add new functionality one feature at a time. Each increment grows the program.
- Iterative means revisiting and improving something that already exists. You go back to a feature you've already built and make it better based on what you've learned since.
Incremental = adding something new. "I didn't have a search feature before; now I do."
Iterative = improving something existing. "I already had a search feature, but I went back and redesigned it."
Ask yourself: is this feature new, or is it a revision of something I already built? New = incremental. Revision = iterative.
2.1 "But if I test each feature before moving on, isn't that iterative?"
This is the most common confusion. The answer: no. Testing a feature as part of finishing it is just good practice — it's part of completing that increment. It becomes iterative only when you go back to a previously completed feature and change it based on something you learned later.
2.2 Concrete Example
Imagine building a budget tracker app:
| Step | What you do | Type |
|---|---|---|
| Week 1 | Build the "add expense" feature. Test it. It works. | Incremental — new feature added |
| Week 2 | Build the "view total" feature. Test it. It works. | Incremental — another new feature added |
| Week 3 | Build the "budget warning" feature. During testing, you realize the "add expense" feature from Week 1 should also save the category. Go back and redesign it. | Incremental (budget warning is new) + Iterative (redesigning "add expense" is a revision) |
| Week 4 | User feedback says the "view total" screen is confusing. Redesign its layout and labels. | Iterative — no new feature, just improving an existing one |
Notice: Weeks 1 and 2 are purely incremental — you added new things and moved on. Week 3 is both — you added something new AND went back to fix something old. Week 4 is purely iterative — nothing new was added, you just improved what was already there.
Incremental
Build up piece by piece
v1 → v1+v2 → v1+v2+v3 → v1+v2+v3+v4
How much of the program is built yet?
Iterative
Revisit and refine
rough → better → better → polished
How many times have you revised it?
Most real development is both: features are added incrementally, and earlier features are revised iteratively as the team learns more. On the exam, the answer that describes going back to improve earlier work is iterative; the answer that describes adding new features is incremental.
§3 Documentation
Documentation is written information about a program — what it does, how to use it, how it works internally. Good documentation includes:
- Comments in code that explain why something is done, not just what
- Description of inputs and outputs for each procedure
- Known limitations and assumptions
- Usage instructions for other developers or end users
Documentation should be written throughout development, not saved for the end. Writing documentation while coding helps you clarify your own thinking and makes collaboration easier.
§4 Four Types of Errors
An error (or bug) is any behavior that prevents a program from working as intended. The exam tests four main types.
| Type | What it is | Example |
|---|---|---|
| Syntax error | Code violates the rules of the language; the program won't run at all. | Missing parenthesis, misspelled keyword |
| Logic error | Code runs but produces the wrong result because the logic is flawed. | Using + when you meant *; wrong IF condition |
| Runtime error | Code runs but crashes partway through due to an illegal operation. | Accessing a list index beyond the length; dividing by zero |
| Overflow error | The result of a calculation is too large for the number of bits used. | Adding two large integers in a fixed-width system |
4.1 Decision Tree: Which Error Type?
§5 Testing Strategies
Testing means running the program with different inputs to find errors. Good tests include:
- Typical inputs — normal values the program is expected to handle.
- Extreme inputs — very large, very small, zero, negative, or empty values.
- Boundary inputs — values right at the edges of valid ranges (e.g., if valid is 1–100, test 1, 100, 0, and 101).
- Invalid inputs — values the program should reject gracefully.
Testing only with inputs you expect to work is the most common mistake. Boundary cases and extreme inputs are where most bugs hide.
5.1 Debugging Approaches
- Hand-tracing — stepping through the code on paper with a specific input, tracking variable values.
- Print/display statements — inserting output commands to reveal variable values during execution.
- Isolating the bug — testing smaller pieces to narrow down where the error occurs.
- Asking a collaborator — a fresh pair of eyes often spots what you're missing.
§6 Debugging Worked Example
The bug: A program sums the odd integers from 1 to n. For n = 5, the expected result is 1 + 3 + 5 = 9.
Line 1: count ← 1
Line 2: sum ← 0
Line 3: REPEAT UNTIL(count > n)
Line 4: {
Line 5: count ← 1
Line 6: sum ← sum + count
Line 7: count ← count + 2
Line 8: }
Line 9: DISPLAY(sum)
Hand-trace for n = 5: Line 5 resets count to 1 every iteration. Line 7 adds 2, making count = 3. Next iteration: Line 5 resets to 1 again. The loop never terminates because count never exceeds n.
Fix: Remove Line 5. The initialization on Line 1 is all that's needed; resetting inside the loop is the bug.
Error type: Logic error. The code runs (no syntax error) and doesn't crash (no runtime error), but it produces the wrong behavior due to flawed logic.
§7 Program Inputs and Outputs
7.1 Inputs
An input is any data a program receives. Inputs can come from many sources:
- User input — text typed, buttons clicked, options selected.
- Events — mouse clicks, screen taps, key presses, gestures. These are inputs that happen at unpredictable times.
- Files and databases — data loaded from storage.
- Sensors — GPS, accelerometer, camera, microphone.
- Other programs — data received over a network or from an API.
7.2 Outputs
An output is anything a program produces:
- Displayed information — text, images, visuals on a screen.
- Files — data saved to storage.
- Signals to devices — sounds, vibrations, motor commands (as in a robot).
- Data sent to other programs — across a network or to another application.
On the exam, "input" is a broader category than you might expect. It includes events (clicks, taps, key presses), sensor readings, and data from other programs — not just what the user types. If a question asks "which of the following is an input," don't overlook events.
§8 Exam Patterns
8.1 "Which input reveals the bug?"
Look for boundary or extreme cases. If the code uses a condition like x > 10, test x = 10 and x = 11. If it handles lists, test empty lists and single-element lists.
8.2 "Which change fixes the program?"
Hand-trace the code with a specific input and compare to the intended output. The fix is the smallest change that makes the trace match the intention.
8.3 "What type of error is this?"
Use the decision tree: doesn't run → syntax; crashes → runtime; produces numbers too big → overflow; runs fine but gives wrong answer → logic.
8.4 "What are the inputs / outputs of the program?"
Anything the program receives is input (events, sensor data, user entries). Anything it produces is output (displays, files, signals). Don't forget events — they are inputs.
§9 Key Terms
| Term | Definition |
|---|---|
| Bug | Informal name for any error in a program |
| Boundary case | An input at the edge of the valid range, where bugs often hide |
| Comment | Text in code meant for humans, ignored by the computer |
| Debugging | The process of finding and fixing errors |
| Development cycle | The iterative process of investigating, designing, prototyping, testing, refining |
| Documentation | Written information about what a program does and how to use it |
| Event | An input that occurs at an unpredictable time (click, tap, key press) |
| Incremental development | Building a program in stages, adding one feature at a time |
| Iterative development | Cycling through development stages multiple times, revising as you learn |
| Logic error | Program runs but produces incorrect results due to flawed reasoning |
| Overflow error | Error caused when a number is too large for its storage |
| Prototype | An early, incomplete version of a program used to test ideas |
| Runtime error | Error that crashes a program during execution |
| Syntax error | Error caused by violating the rules of the programming language |
| Testing | Running a program with various inputs to check for errors |
§10 Self-Check
- Why is the development cycle a loop rather than a straight line?
- What is the difference between iterative and incremental development? If a developer tests and fixes each feature before moving to the next, is that iterative, incremental, or both?
- Classify each as syntax, logic, runtime, or overflow: (a) a program forgets a closing parenthesis and refuses to run; (b) a program tries to access list[0] when indices start at 1; (c) a program returns 7 when it should return 12; (d) a calculator stores results in 8-bit integers and produces garbage when computing 200 + 200.
- A student tests their program only with inputs they know will work and concludes it is bug-free. What is wrong with this approach?
- List three things that count as inputs to a program besides typing text.
- Why should documentation be written throughout development rather than only at the end?
Show Answers
- Because testing almost always reveals things that require going back to earlier stages. Design flaws may only become obvious during prototyping; user feedback during testing may change the original requirements.
- Incremental means adding new functionality that didn't exist before — the program grows. Iterative means going back to revise and improve something that already exists. Testing a feature as you build it is just finishing the increment — it becomes iterative only when you return to a previously completed feature and change it based on new understanding. Yes, most real projects are both: features are added incrementally, and earlier features are revised iteratively as the team learns more.
- (a) Syntax — won't run due to a language rule violation. (b) Runtime — runs but crashes when it hits the illegal index. (c) Logic — runs without crashing but gives the wrong answer. (d) Overflow — the result exceeds the 8-bit storage capacity.
- Bugs rarely show up on inputs the programmer already thought about. Real bugs hide in edge cases, unexpected inputs, and combinations the programmer didn't consider. Without testing those, the program is untested, not bug-free.
- Any three of: events (clicks, taps, key presses), sensor data (GPS, accelerometer), files, data from other programs, data from a network, camera or microphone input.
- Writing documentation while coding helps clarify your own thinking, catches design problems early, and keeps knowledge accessible to collaborators. Documentation written at the end is often rushed, incomplete, or omitted entirely.