AP Computer Science Principles · Study guide

Big Idea 1: Development Process, Errors & Testing

Big Idea 1 · Creative Development · Part 2 of 2

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.

Exam-day recap
  • 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.

Development is a loop, not a straight line. Testing often reveals problems that send you back to design or even investigation.
Key rule

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.
The key distinction

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:

StepWhat you doType
Week 1Build the "add expense" feature. Test it. It works.Incremental — new feature added
Week 2Build the "view total" feature. Test it. It works.Incremental — another new feature added
Week 3Build 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 4User 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?

Key idea

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.

TypeWhat it isExample
Syntax errorCode violates the rules of the language; the program won't run at all.Missing parenthesis, misspelled keyword
Logic errorCode runs but produces the wrong result because the logic is flawed.Using + when you meant *; wrong IF condition
Runtime errorCode runs but crashes partway through due to an illegal operation.Accessing a list index beyond the length; dividing by zero
Overflow errorThe 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?

Follow the questions to identify the error type. This decision tree covers every error-classification question on the exam.

§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.
Common pitfall

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

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.
Definition · Events as Inputs

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

TermDefinition
BugInformal name for any error in a program
Boundary caseAn input at the edge of the valid range, where bugs often hide
CommentText in code meant for humans, ignored by the computer
DebuggingThe process of finding and fixing errors
Development cycleThe iterative process of investigating, designing, prototyping, testing, refining
DocumentationWritten information about what a program does and how to use it
EventAn input that occurs at an unpredictable time (click, tap, key press)
Incremental developmentBuilding a program in stages, adding one feature at a time
Iterative developmentCycling through development stages multiple times, revising as you learn
Logic errorProgram runs but produces incorrect results due to flawed reasoning
Overflow errorError caused when a number is too large for its storage
PrototypeAn early, incomplete version of a program used to test ideas
Runtime errorError that crashes a program during execution
Syntax errorError caused by violating the rules of the programming language
TestingRunning a program with various inputs to check for errors

§10 Self-Check

  1. Why is the development cycle a loop rather than a straight line?
  2. 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?
  3. 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.
  4. A student tests their program only with inputs they know will work and concludes it is bug-free. What is wrong with this approach?
  5. List three things that count as inputs to a program besides typing text.
  6. Why should documentation be written throughout development rather than only at the end?
Show Answers
  1. 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.
  2. 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.
  3. (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.
  4. 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.
  5. 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.
  6. 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.