Collaboration is people sharing the planning, building and testing of a program. A team with varied backgrounds questions more assumptions and notices users one programmer would miss, so it reduces bias. It runs on pair programming, a shared plan, specific feedback and online tools such as version control.
Quick check
What does this code segment display? x ← 4, then x ← x + 3, then DISPLAY(x)Show answerHide answer
It displays 7.
xstarts at 4, and the second line adds 3 to it.Who is more likely to question an assumption in a program: its writer or a classmate seeing it fresh?Show answerHide answer
The classmate. The writer tends to read what they meant to write; a fresh reader sees only what is there.
Know these already? Jump to the practice questions
What you'll be able to do
- Explain how varied perspectives reduce bias.
- Describe the two roles in pair programming.
- Identify what teammates agree on before coding separately.
- Predict what two teammates' combined code does.
Key terms
Pair programming
Two programmers sharing one task: the driver types, the navigator reviews each line and keeps the plan in mind, and they swap roles regularly.
- In plain English
- One types, one checks, then you trade.
- Don't write
- "The navigator writes a second copy of the code."
Bias
A pattern in a computing innovation (a program, app or device that depends on code) that gives worse results for some groups, often because they were left out of its design, testing or data.
- In plain English
- It works better for some people than for others.
- Don't write
- "Bias only happens when a programmer means to be unfair."
Version control
Software that records each change to a project's files, with its author and time, so a team can return to an earlier version.
- In plain English
- A project history you can rewind.
- Don't write
- "Version control stops bugs from being saved."
Why do diverse teams build better innovations?
Every programmer brings assumptions about which devices people own, which language they read, or how they see and move. A team whose members differ in background, ability and experience questions more of them before they become code. A design built around one kind of user can serve everyone else worse, which is bias.
Bias also enters through data. In a 2019 test of 189 face-recognition algorithms, the U.S. National Institute of Standards and Technology (NIST) found that many of them made false matches at higher rates for some demographic groups, with differences linked to age, sex and race. A team that includes and tests with the people a product will affect is more likely to find such a gap before release. Collaboration does not remove bias automatically; it widens who checks for it.
Key idea
Varied perspectives catch assumptions one person cannot see, so collaboration helps reduce bias.
Check yourself
Show answerHide answer
They have needs the programmers may not share, so their tests reveal where the design serves some users worse.
How does pair programming work?
Two people share one computer, or one shared screen online. The driver types. The navigator reads each line as it appears, asks questions, spots mistakes and keeps the plan in mind. Swapping roles helps both understand all of the code.
Errors can be caught as they are typed, before other code is built on them, and talking a choice through often exposes a weak one. The navigator's sharpest tool is tracing: running the code by hand on a test input and comparing the result with the plan, as in Worked example 2.
Check yourself
Show answerHide answer
The navigator. The driver is the one typing.
What must a team agree on before splitting the work?
A procedure is a named group of instructions that runs when it is called; a parameter is an input variable named in its header. When teammates code separately, they first agree:
| Decision | Example |
|---|---|
| Who builds what | Ana writes total; Ben calls it |
| Name and parameters | total(prices) takes one list |
| What it gives back | It returns the sum; it does not display it |
If Ana's procedure displays the sum while Ben's code stores a returned value, each part looks right alone and the program still fails. Settle disagreements by testing each idea against the program's purpose and users.
Check yourself
Show answerHide answer
Its parameters and what it gives back (a returned value or a display), so Ben's call matches Ana's procedure.
What makes feedback useful, and what do online tools add?
Feedback is information about how well a program meets its purpose, from teammates, testers or users. Useful feedback names the input or screen, is about the work rather than the person, and makes clear what should change. "The app is confusing" is hard to act on; "entering 0 guests showed an error" names an input and a result, so the team can repeat the test. (See Developing Programs Iteratively.)
Online tools let a team work apart. Shared documents hold the plan; shared coding environments let pairs edit the same code live. Version control, such as Git, keeps every saved version with its author and time, so teammates can combine their changes and undo one that broke something.
Check yourself
Show answerHide answer
Version control, because it keeps each saved version with its author and time.
Worked example 1: Choose the change that reduces bias
Question: Four first-language English speakers build a voice-ordering app for school lunch and test it only on each other. Which change is most likely to reduce bias in the app?
- A) Each member tests it twice as often.
- B) It responds faster.
- C) The menu offers more items.
- D) Students with varied accents test it, and some join the team.
What tells you the method
The question asks about bias, so look for the option that changes who designs or tests the app.
Step 1: Find whose needs were missing.
Speech unlike the four members' was never tried.
WhyBias comes from the people and data left out.
Step 2: Test each option against that gap.
A repeats the same voices; B and C change speed and menu. Only D brings in the missing speakers.
WhyOnly the missing perspectives can reveal the gap.
Check it
Only D would catch a student whose accent the app misreads.
Answer
D
Worked example 2: Trace the driver's code as navigator
Question: The pair's plan says a score of 70 or more passes. What does countPassing([65, 70, 92]) return?
PROCEDURE countPassing(scores)
{
count ← 0
FOR EACH s IN scores
{
IF(s > 70)
{
count ← count + 1
}
}
RETURN(count)
}
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.
FOR EACHgivesseach element in order, first to last (on the exam reference sheet).Pass ss > 70countstart 0 1 65 false 0 2 70 false 0 3 92 true 1 Whycountgoes up only when the condition is true.Step 2: Compare with the plan.
The plan counts 70 as a pass, so the result should be 2. The navigator points to
s > 70, which should bes ≥ 70.WhyTracing a value equal to the limit catches a wrong comparison.
Check it
With s ≥ 70, pass 2 is true, so count ends at 2, matching the plan.
Answer
1
Worked example 3: Plan, split and combine
Question: Orders totaling more than 20 dollars get 5 dollars off. Ana writes total; Ben writes the code that uses it. What is displayed?
PROCEDURE total(prices)
{
sum ← 0
FOR EACH p IN prices
{
sum ← sum + p
}
RETURN(sum)
}
cart ← [12, 5, 8]
cost ← total(cart)
IF(cost > 20)
{
cost ← cost - 5
}
DISPLAY(cost)
What tells you the method
Two people's code: check the agreed split, then trace the procedure and the code that calls it.
Step 1: State the input, output and split.
Input: a list of prices; output: the discounted cost.
totalreturns the sum; Ben's code applies the discount.WhyBecause
totalreturns rather than displays, Ben can store its result incost.Step 2: Trace
total(cart).sumgoes 0, 12, 17, 25, so it returns 25.WhyBen's code depends on this value, so check it first.
Step 3: Trace Ben's code.
25 > 20is true, socostbecomes 20, andDISPLAYshows it.WhyThe discount applies only when the condition is true.
Check it
At the boundary, [10, 6, 4] totals 20; 20 > 20 is false, so 20 is displayed with no discount, matching "more than 20 dollars".
Answer
20
Your turn
Question: A quiz app's version history shows:
| Version | Change | Test result |
|---|---|---|
| 1 | First working quiz | Passed |
| 2 | Added a timer | Passed |
| 3 | Added a score screen | Passed |
| 4 | Changed how points are added | Score always 0 |
Which version should the team return to, undoing only the change that broke the score?
Step 1: Find the breaking change.
Only version 4 failed, so its scoring change is the fault.
Step 2: Your go: decide which version is the last one that passed and still has the timer and the score screen.
Show the full solutionHide the solution
Step 2. Version 3 passed and includes the quiz, the timer and the score screen. Returning to version 2 would also lose the working score screen.
Answer: 3
Traps
Trap
Skilled programmers avoid bias as long as nobody means to be unfair.
It seems right because bias sounds deliberate. But bias often comes from who was left out of design and testing, or from unrepresentative data, so good intentions do not prevent it.
Can a program be biased if no one intended it?
Yes. Bias can come from people left out of design and testing, or from the data used.
Trap
In pair programming, the navigator waits while the driver works.
It seems right because only the driver types. But the navigator works throughout: reviewing each line and tracing it against the plan.
Name one thing the navigator does while the driver types.
Reviews each line for mistakes, traces it on a test input, or tracks the overall plan.
What's examined
On the AP® Computer Science Principles exam, collaboration belongs to Big Idea 1: Creative Development. Multiple-choice questions describe a team and ask which practice helps, or what two people's combined code does. For the Create performance task, follow College Board's current rules and your teacher's on partners.
Practice questions
- Recall Which statement describes the navigator in pair programming?
- A) The partner who types the code.
- B) The partner who reviews each line as it is typed and keeps the plan in mind.
- C) The partner who tests the program afterward.
- D) The partner who writes a separate version.
Show answer
Answer: B. The navigator reviews the code as it is typed and keeps the plan in view.
Why the others are wrong:
- A describes the driver.
- C describes testing afterward, not a pair-programming role.
- D describes two people working separately.
- Apply Which tester comment on a step-counter app is most useful to act on?
- A) "Entering 0 steps for a day made the weekly average show an error."
- B) "The app feels a bit off."
- C) "Whoever wrote the average code was careless."
- D) "It would be better if it were easier."
Show answer
Answer: A. It names an input and a result, so the team can repeat the test.
Why the others are wrong:
- B gives no input or result to investigate.
- C is about a person, not the work.
- D does not say what should change.
- Apply A navigator traces the call
maxValue([3, 9, 4, 9]). How many times does the linebest ← xrun?
PROCEDURE maxValue(nums)
{
best ← nums[1]
FOR EACH x IN nums
{
IF(x > best)
{
best ← x
}
}
RETURN(best)
}
Show answer
Answer: 1
Marking points:
beststarts atnums[1], which is 3, because list indexes start at 1.- Pass 1:
3 > 3is false. Pass 2:9 > 3is true, sobestbecomes 9. - Passes 3 and 4:
4 > 9and9 > 9are false, because>needs strictly greater.
- Exam-style A team is designing a homework-planner app for a whole high school. Which team is most likely to produce an app that works well for all its students?
- A) Five seniors in the same advanced classes.
- B) The two fastest programmers in the class.
- C) Students from different grades and course loads, including one who uses a screen reader.
- D) One programmer alone, for a consistent design.
Show answer
Answer: C. It brings the most varied perspectives, including a user whose needs others might overlook.
Why the others are wrong:
- A shares one grade and course load, so many students' needs go unseen.
- B values speed, which does not widen whose needs are considered.
- D leaves one person's assumptions unchecked.
- Exam-style Two teammates combine their code. What is displayed?
PROCEDURE double(n)
{
RETURN(n * 2)
}
values ← [3, 6]
FOR EACH v IN values
{
DISPLAY(double(v) + 1)
}
Show answer
Answer: 7 13
Marking points:
- Pass 1:
double(3)returns 6, and 6 + 1 is 7. - Pass 2:
double(6)returns 12, and 12 + 1 is 13. - Each
DISPLAYshows its value followed by a space, so both appear on one line.
Key points
Recall, then reveal
Say the main points from memory first, then check them.
Show key pointsHide key points
- Teams with varied backgrounds spot assumptions that would otherwise become bias, especially when future users help design and test.
- In pair programming the driver types, the navigator reviews and traces, and the roles swap.
- Before splitting work, agree each procedure's name, parameters and whether it returns or displays.
- Useful feedback names an input and a result, targets the work, and says what should change.
- Version control keeps every change with its author, so a team can combine work and roll back.