Programs are built in repeated cycles: investigate what users need, design, build a prototype, test it, and refine it. Iterative development repeats that whole cycle; incremental development builds and tests one small piece at a time. Throughout, documentation explains the code, and borrowed code or ideas are credited.
Quick check
"It shows each day's rainfall total." Is that a program's purpose or its function?Show answerHide answer
Its function: it says what the program does when it runs, not why it was made.
Users try a rough first version of an app and suggest changes. What should the team do next?Show answerHide answer
Revise the app and test the new version again, which starts another cycle of development.
Know these already? Jump to the practice questions
What you'll be able to do
- Describe the stages of a development cycle.
- Distinguish iterative from incremental development.
- Choose documentation that accurately describes a procedure.
- Explain how to acknowledge code or ideas from others.
- Predict what a revised procedure returns.
Key terms
Iterative development
Building a program through repeated cycles of designing, testing and revising, each version improved by feedback and test results.
- In plain English
- Build it, test it, improve it, repeat.
- Don't write
- "Iterative development means writing a loop."
Incremental development
Building a program in small pieces, making sure each piece works before adding the next.
- In plain English
- One tested piece at a time.
- Don't write
- "Incremental development means writing everything, then testing at the end."
Prototype
An early, rough working version of a program, built to test ideas with users.
- In plain English
- A first draft you can try out.
- Don't write
- "A prototype is the finished program."
Documentation
A written description of what a program or code segment does and how to use it. Comments are documentation inside the code; they do not change how it runs.
- In plain English
- Notes that explain the code to people.
- Don't write
- "Comments make the program run faster."
What happens in each development cycle?
A cycle has five stages, and the team often loops back between them:
- Investigate: find out what users need through surveys, interviews, watching people use similar tools, and testing earlier versions. Note limits too, such as the devices users have.
- Design: decide the inputs, outputs, procedures and data, and sketch the screens.
- Prototype: build a rough version that works well enough to try.
- Test: run it with chosen inputs and with real users.
- Refine: fix errors and change the design based on what testing and feedback showed.
Investigation never fully stops: a user test can reveal a need nobody mentioned in the survey, sending the team back to design.
Check yourself
Show answerHide answer
Investigating: the team is finding out what users need before designing.
How do iterative and incremental development differ?
| Iterative | Incremental | |
|---|---|---|
| What repeats | The whole cycle, on the whole program | Build and test, one piece at a time |
| What drives the next step | Feedback and test results | The previous piece working |
| Main benefit | The program moves closer to what users need | When a test fails, the error is probably in the newest piece |
Most projects combine them. A team adds a sign-in screen as one increment, tests it, and may revise it several times before starting the next increment.
Key idea
Iterative means revise and repeat; incremental means add one tested piece at a time.
Check yourself
Show answerHide answer
No. Incremental development tests each piece before adding the next.
Why document code as you write it?
Documentation tells a reader what a procedure does, what its parameters mean, what it returns, and any limits on its inputs. Teammates use it to call your procedure correctly, and you use it when you return to the code weeks later.
Write it during development, not at the end: you know your reasons best while writing the code, and teammates need it before they call your procedures. A useful comment explains what and why, not a restatement of one line. Documentation for one procedure might read:
countAbove(nums, limit)
Returns how many values in nums are greater than limit.
nums is a list of numbers; limit is a number.
Check yourself
Show answerHide answer
No. Comments are for people reading the code; the program ignores them when it runs.
How do you credit code and ideas from others?
Programmers often reuse code, images, sounds and ideas from others. When you do, acknowledge it: in a comment or the documentation, name the author or source and say where you found it. Credit applies even when you changed the code or had permission to use it.
Permission and credit are different things. A license states what others may do with a work. Creative Commons licenses let creators give permission in advance on stated terms, and every one of them requires users to credit the creator. Renaming variables does not make borrowed code your own.
For your Create performance task, follow College Board's current rules and your teacher's on using code written by others.
Check yourself
Show answerHide answer
Yes. Permission lets you use it; the credit shows readers where it came from.
Worked example 1: Spot incremental development
Question: Which entry in a team's project log is an example of incremental development?
- A) Surveyed classmates about when they study.
- B) Built and tested the sign-in screen, then started the timetable only after sign-in worked.
- C) Wrote all five screens, then tested them together for the first time.
- D) Changed the colors after users said the text was hard to read.
What tells you the method
"Incremental" means pieces, each tested before the next, so look for that order.
Step 1: Remove the other stages.
A is investigating; D is refining after feedback, which is iteration.
WhyNeither adds one tested piece.
Step 2: Compare B and C.
B tests one piece before starting the next. C tests nothing until everything is written.
WhyIn C, an error could be in any of five screens.
Check it
Only in B does each new piece start from a tested base.
Answer
B
Worked example 2: Trace the refined version
Question: Version 1 of a rain-gauge procedure added every reading. Testing showed the sensor sends -1 when it fails, so version 2 skips negative readings. What does version 2 return for total([3, -1, 0, 5])?
PROCEDURE total(readings)
{
sum ← 0
FOR EACH r IN readings
{
IF(r ≥ 0)
{
sum ← sum + r
}
}
RETURN(sum)
}
What tells you the method
A call with a given list, so trace the loop with one row per pass.
Step 1: Trace each pass.
Pass rr ≥ 0sumstart 0 1 3 true 3 2 -1 false 3 3 0 true 3 4 5 true 8 WhyA reading is added only when the condition is true.
Step 2: Compare with version 1.
Version 1 adds -1 too, giving 7. Version 2 gives 8, the true rainfall.
WhyComparing versions on the same input confirms the refinement fixed the problem testing found.
Check it
Pass 3 is the boundary: 0 ≥ 0 is true, so a dry day's 0 is included, which leaves sum unchanged anyway.
Answer
8
Worked example 3: Choose accurate documentation
Question: Which documentation accurately describes this procedure?
PROCEDURE countAbove(nums, limit)
{
count ← 0
FOR EACH n IN nums
{
IF(n > limit)
{
count ← count + 1
}
}
RETURN(count)
}
- A) Loops through
nums. - B) Returns how many values in
numsare greater than or equal tolimit. - C) Returns how many values in
numsare greater thanlimit. - D) Displays the values in
numsthat are greater thanlimit.
What tells you the method
Documentation must match the code exactly, so check each option against the condition and the output.
Step 1: Read the code.
It counts values with
n > limitand returns the count; it never displays.WhyThe condition and the
RETURNdecide what the documentation must say.Step 2: Test the options.
A is true but useless. B includes values equal to
limit, which>does not. D says displays, not returns. C matches.WhyAn off-by-one boundary in documentation misleads every teammate who reads it.
Check it
Trace countAbove([4, 9, 6, 9], 6): only the two 9s pass n > 6, so it returns 2, as C predicts; B would predict 3.
Answer
C
Your turn
Question: Version 1 of rainyDays(readings) counted readings with r ≥ 0. Users said a reading of 0 is a dry day, so version 2 counts readings with r > 0. What does version 2 return for rainyDays([3, -1, 0, 5])?
Step 1: Check the first two readings.
3 > 0is true, so the count is 1.-1 > 0is false, so it stays 1.Step 2: Your go: check 0 and 5 and give the final count.
Show the full solutionHide the solution
Step 2. 0 > 0 is false, so the count stays 1. 5 > 0 is true, so the count becomes 2. Version 1 would have returned 3, counting the dry day.
Answer: 2
Traps
Trap
Iterative development means the program uses loops.
It seems right because iteration also names a loop in code. But iterative development is a way of working: repeating the design, test and revise cycle on the whole program.
A team revises its app three times after rounds of user testing. Is that iterative development, even if the code has no loops?
Yes. The repeated revise-and-test cycle is what makes it iterative.
Trap
Code you had permission to use needs no credit.
It seems right because permission feels like the whole issue. But permission and credit are separate: you still name the author and source.
Does changing a borrowed procedure's variable names remove the need to credit it?
No. The work is still based on someone else's code, so it still needs credit.
What's examined
On the AP® Computer Science Principles exam, this belongs to Big Idea 1: Creative Development. Multiple-choice questions describe a team's process and ask which stage or approach it shows, which documentation fits a procedure, or how to acknowledge borrowed code. Developing and documenting your own Create program iteratively is the same method in practice.
Practice questions
- Recall Which activity belongs to investigating what users need?
- A) Interviewing students about how they track homework.
- B) Writing the procedure that saves each assignment.
- C) Fixing a bug found during testing.
- D) Adding comments to the code.
Show answer
Answer: A. Interviews gather users' needs before or between designs.
Why the others are wrong:
- B is building the program.
- C is refining after testing.
- D is documentation.
- Recall Name the approach that builds a program one piece at a time, testing each piece before adding the next.
Show answer
Answer: Incremental development
Marking points:
- Each piece is tested before the next is added, so a new error is usually in the newest piece.
- Apply Which documentation accurately describes this procedure?
PROCEDURE lastItem(aList)
{
RETURN(aList[LENGTH(aList)])
}
- A) Returns the first element of
aList. - B) Returns the number of elements in
aList. - C) Displays the last element of
aList. - D) Returns the last element of
aList;aListmust not be empty.
Show answer
Answer: D. Indexes start at 1, so LENGTH(aList) is the index of the last element; an empty list has no element there.
Why the others are wrong:
- A: the first element is at index 1, not index
LENGTH(aList). - B confuses the index
LENGTH(aList)with the element stored there. - C: the procedure returns the value; it does not display it.
- Apply Version 2 of a game's scoring procedure is below. What does
bonus(50)return?
PROCEDURE bonus(points)
{
result ← points
IF(result ≥ 50)
{
result ← result + 10
}
IF(result > 55)
{
result ← result * 2
}
RETURN(result)
}
Show answer
Answer: 120
Marking points:
50 ≥ 50is true, soresultbecomes 60.- The second
IFis separate, so it tests the new value:60 > 55is true, soresultbecomes 120.
- Exam-style Maya finds a procedure for shuffling a list in an online tutorial whose license allows reuse with credit. What should she do to use it?
- A) Nothing: code published online is free to use.
- B) Use it and add a comment naming the tutorial's author and where she found it.
- C) Rename its variables so the code counts as her own.
- D) Use it only after deleting the original author's comments.
Show answer
Answer: B. The license requires credit, and a comment naming the author and source gives it.
Why the others are wrong:
- A ignores the license's condition.
- C hides the source; renaming does not create new work.
- D removes information about the source instead of adding credit.
- Exam-style Five users test a prototype quiz app and say the questions disappear before they can read them. In iterative development, what should the team do next?
- A) Release the app, since the prototype works.
- B) Abandon the app and start a new idea.
- C) Revise the timing, then test the new version with users again.
- D) Add more questions before changing anything.
Show answer
Answer: C. Iteration means revising from feedback, then testing again.
Why the others are wrong:
- A ignores the feedback.
- B throws away a design that needs only one change.
- D adds features while a known problem remains.
Key points
Recall, then reveal
Say the main points from memory first, then check them.
Show key pointsHide key points
- A development cycle investigates, designs, prototypes, tests and refines, and often loops back.
- Iterative development revises the whole program from feedback; incremental development adds one tested piece at a time.
- Good documentation states what a procedure returns, what its parameters mean and any limits on input.
- Credit borrowed code and ideas by naming the author and source, even with permission.
- Compare versions on the same input to confirm a refinement fixed what testing found.