How Programs Are Made
Follow the iterative development process, see why collaboration and documentation matter, and learn to tell syntax, logic, run-time and overflow errors apart.
Welcome back!
Step 1 of 10Learn
Programs are built in loops, not lines
When Jamal's school asked students to build an app that helps classmates find study partners, his team didn't start by typing code. They interviewed ten classmates, listed what people actually needed (filtering by subject, a way to pick meeting times), sketched screens on paper, and only then wrote a first small version. They tested it, found that nobody understood the "match" button, renamed it, and tested again.
That cycle is the development process, and in computer science it's usually iterative: you design, build, test and reflect, then go around again, each time improving the program. Some teams instead work incrementally, finishing one small piece completely, such as login, before adding the next. Most real projects mix both.
The process typically includes:
- Investigating and reflecting: figuring out the purpose and the users' needs through surveys, interviews and observation.
- Designing: planning the user interface, breaking the problem into parts and choosing algorithms.
- Prototyping: building a rough working version to test ideas quickly.
- Testing: running the program with many inputs, including unusual ones, to find problems.
A program's purpose is the problem it solves or the creative goal it serves. Its function is how it behaves when it runs. Keeping the purpose in mind is what tells you which feedback to act on.
Step 2 of 10Practice · Put in order
Put the stages of one iteration of a development cycle in a sensible order.
Drag the items, or use the arrow buttons, to put them in order.
- Build a prototype
- Test the prototype with real users
- Reflect on feedback and plan the next round
- Investigate what users need
- Design the interface and plan the algorithms
Step 3 of 10Learn
Collaboration and documentation
Almost all real software is built by teams. Collaboration helps for a practical reason: people with different backgrounds and perspectives notice different problems. A student who uses a screen reader will spot accessibility issues instantly; someone who rides the bus to school may suggest features that drivers never consider. Diverse teams tend to build programs that work for more people and contain fewer blind spots.
Common collaboration practices include pair programming, where one person types (the driver) while the other reviews and thinks ahead (the navigator), switching roles often; shared online code repositories; and splitting a program into parts with clearly agreed inputs and outputs.
Teams rely on documentation: written descriptions of what code does and how to use it. Comments are notes inside the code that the computer ignores. They help others, and your future self, understand why the code works the way it does. Good documentation is written during development, not at the end, because that's when you still remember the reasons behind each choice.
Finally, when you use code written by someone else, such as a library or a snippet from a tutorial, you must give credit in your documentation. Acknowledging sources is both honest and, on the AP Create performance task, required.
Step 4 of 10Practice · Select all that apply
Which practices help a team develop a program effectively? Select all that apply.
Select all that apply.
Step 5 of 10Learn
Four kinds of errors
Every programmer writes bugs. The skill is recognizing what kind of error you're facing, because each kind is found differently.
- Syntax error: the code breaks the language's rules, such as a missing parenthesis or a misspelled keyword. The program won't run at all, and the computer usually points to the line.
- Logic error: the program runs but produces the wrong result, because the algorithm itself is wrong. Using
<instead of<=, or adding when you meant to multiply, are logic errors. The computer can't detect these; only testing reveals them. - Run-time error: the program starts but fails while running, often on certain inputs, such as dividing by zero or accessing a list element that doesn't exist.
- Overflow error: a number is too large to fit in the fixed number of bits a computer uses to store it. You'll see why that happens in the next lesson.
To find errors, programmers use test cases: chosen inputs with known expected outputs. Good test cases include normal values, boundary values (the edges, like 0, the maximum, or exactly the cutoff for a grade), and unusual ones such as empty lists. Other tools include hand tracing (stepping through code with pencil and paper), adding output statements to display variable values, and using a debugger to pause the program line by line.
Step 6 of 10Compare
Four kinds of errors
| Aspect | Syntax | Run-time | Logic | Overflow |
|---|---|---|---|---|
| What happens | Program will not run | Crashes while running | Runs, wrong result | Number too big for its bits |
| Example | Missing parenthesis | Dividing by zero | Using < instead of <= | Adding 1 to the largest value |
| How you find it | Computer points to the line | Certain inputs make it fail | Only testing reveals it | Testing very large values |
Step 7 of 10Practice · Sort into groups
Classify each bug.
Tap an item, then tap its group (or drag it there).
Step 8 of 10Note
Step 9 of 10Tap to reveal
Pick test cases for "ages 13 to 18 can join"
Normal value
Age 15 should be accepted. It shows the basic logic works, but it misses most bugs.
Lower boundary
Test 12 (reject) and 13 (accept). A
>where you needed>=fails here.Upper boundary
Test 18 (accept) and 19 (reject). Off-by-one mistakes hide at both edges.
Unusual input
Try 0, a negative number or an empty field. Good programs handle these without crashing.
Step 10 of 10Practice · What would you do?
What would you do?
A program should give free shipping on orders of $50 or more. Testing shows that an order of exactly $50 is charged shipping, but $50.01 ships free. The program runs without crashing. What kind of error is this, and where should the programmer look?
Lesson complete!