Skip to content

Course navigation

For teachersTopic 4.1 · Lesson kit

Ethical and Social Issues Around Data Collection

  • 2 class periods
  • 45 minutes each
  • Objectives 4.1.A, 4.1.B, 4.1.C
  • 6 downloads with keys

Downloads

  • Slides

    Speaker notes on every slide

  • Lesson plan

    2 periods of 45 minutes

  • Worksheet

    Puzzles, about 30 minutes

  • Worksheet key

    Answer key

  • Exit ticket

    End of the last period

  • Exit ticket key

    Answer key

Download all AP CSA teacher filesEvery topic's slides, lesson plan, worksheet, and exit ticket, with keys (.zip)

At a glance

Pacing
2 class periods of 45 minutes
Learning objectives
4.1.A4.1.B4.1.C
Essential knowledge
4.1.A.14.1.B.14.1.B.24.1.B.34.1.C.1
Materials
Projector and the Handle With Care slide deckWhiteboard and markersSticky notes or scrap paper for the closuresIDE on the teacher computer for demonstrationsPrinted Handle With Care puzzle worksheet (answer key for you) and exit ticket

45 minutes a day

Agenda

Day 145 minutes

  • Warm-up
  • Direct instruction
  • Closure
  • Activity
  1. 0:00–0:055 minWarm-upwhat does the app really need? (slide 2)
  2. 0:05–0:1712 minDirect instructionpersonal data, privacy risks, safeguards (slides 3–7)
  3. 0:17–0:247 minDirect instructionshow only what the user needs (slide 8)
  4. 0:24–0:284 minActivityDay 1 pause and try — the bus app (slide 9)
  5. 0:28–0:4012 minDirect instructionalgorithmic bias (slides 10–13)
  6. 0:40–0:455 minClosureglitch or bias?

Day 245 minutes

  • Warm-up
  • Direct instruction
  • Guided practice
  • Closure
  • Exit ticket
  • Activity
  1. 0:00–0:055 minWarm-upis this algorithmic bias?
  2. 0:05–0:1510 minDirect instructioncollection method and bias (slides 14–16)
  3. 0:15–0:238 minDirect instructionincomplete and inaccurate data (slide 17)
  4. 0:23–0:296 minActivityDay 2 pause and try — what went wrong with the data? (slide 18)
  5. 0:29–0:378 minGuided practicedoes this data set fit? (slides 19–20)
  6. 0:37–0:403 minClosurefive questions to ask about data (slides 21–22)
  7. 0:40–0:455 minExit ticket

Overview

Topic 4.1 opens Unit 4. Before students store many values in arrays, they look at where data comes from and what can go wrong with it. Day 1 is about people: collecting and storing personal data puts privacy at risk, and programmers should design programs to safeguard it (4.1.A.1); then algorithmic bias, a systemic, repeated error that is unfair to a specific group (4.1.B.1). Day 2 is about the data itself: a biased collection method makes conclusions wrong (4.1.B.2), incomplete or inaccurate data makes a correct program give wrong results or waste work (4.1.B.3), and a data set gathered for one question may not answer a different one (4.1.C.1).

This is a discussion-heavy topic. The Java is short and only illustrates the ideas: String methods from Topic 1.15 (length, substring, indexOf), int arithmetic, if statements and loops from Unit 2, and a public static method from Unit 3. Stay inside the boundary: no arrays or ArrayList yet, so every “data set” in code is a handful of separate values. Don’t stop to explain arrays when a student asks how a real app would store thousands of values; say that is exactly what the rest of the unit teaches.

Teacher note

The slides are the Handle With Care deck (22 slides, with speaker notes); slide numbers below refer to it. Day 1 uses slides 1–13 and Day 2 uses slides 14–22. The deck’s closure (slide 22) hands out the worksheet; with two days, hand it out at the end of Day 1 instead.

The Handle With Care puzzle worksheet has 10 questions and takes about 30 minutes. Questions 1–5 (Parts A and B: privacy and algorithmic bias) need only Day 1 and are Day 1 homework; questions 6–10 (Part C: collection method, incomplete and inaccurate data, data fit, vocabulary) are Day 2 homework. The Think First box on page 1 is settled by question 2.

Demonstrations come from the topic’s examples/ folder (.snippet.java files hold only the statements for main): MaskPhone, MaskPhoneFixed, MaskEmail, NameCheck, NameCheckFixed (Day 1); SpaceCheck, SurveyGym, SurveyHomeroom, StepAverage, StepAverageSkipMissing, StepAverageTypo (Day 2). Every app, school, and person in the deck, worksheet, and examples is made up; keep real-company stories short and factual if students bring them up.

Day 1 · Warm-up: What does the app really need?

Show slide 2. Pairs get two minutes to decide which of the five items a free weather app needs. A forecast needs only a rough location (city or ZIP code); it needs no contacts, photos, birthday, or exact location every minute. Then ask: “What could happen to the rest if the app kept it?” Collect a few ideas (a leak, the data sold, someone tracking you) and write them on the board; they become the four risks on slide 5.

Day 1 · Direct instruction: Personal data, privacy risks, safeguards

  1. Goals (slide 3). Read the five goals; the first two are today’s, the last three are Day 2’s.
  2. Personal data and privacy (4.1.A.1, slides 4–5). Personal data is information about a specific person; privacy is a person’s ability to control who knows it. Go through the four risks on slide 5 (seen, misused, combined, kept) and match each to an idea from the warm-up board. Stress the line at the bottom: none of them needs a bug. A program that works perfectly still holds the data.
  3. Harmless pieces add up (slide 6). Walk down the funnel: a birthday matches about 3 students, adding grade narrows it to 1 or 2, adding the chess team narrows it to exactly 1. Ask: “Which field would you remove to make the set safer?” Any one helps, but the real lesson is to collect only what the program needs.
  4. Safeguards (4.1.A.1, slide 7). Programmers decide how much risk users carry, and users usually cannot see the code. Go through the six habits. Ask students to rank them; land on the slide’s answer: the strongest habit is collecting only what is needed, because data that was never collected can never be exposed, misused, or combined.

Misconception: I have nothing to hide, so privacy does not matter

Students treat privacy as being about secrets. Point back to slide 5: the risks are about safety and control (a stranger learning where you live, an email list sold without asking). Ask, “Would you post your home address and the times you are home alone on the class website?” Everyone has something they don’t want everyone to know.

Misconception: Collect everything now, just in case

Extra fields feel like good planning. Every extra field is extra risk for the user with no benefit today. Use the warm-up: the weather app gains nothing from your photos, and a leak would expose them anyway. Give students the test to ask of every field: “Does the program need this to do its job now?”

Day 1 · Direct instruction: Show only what the user needs

  1. Trace slide 8. The card number has 16 characters, so card.length() - 4 is 12, and substring(12) returns "6677". Ask: “Why card.length() - 4 instead of typing 12?” It works for numbers of any length.
  2. Demo MaskPhone then MaskPhoneFixed in the IDE. The first version prints the full phone number and then the masked one; ask which line shows more than the user needs (line 3, the full number), delete it, and run the fixed version: Reminder goes to the number ending in 8342.
  3. Vary the data. Show MaskEmail and ask students to predict the output before running it: Code sent to j***@example.com. indexOf("@") is 10, and substring(10) keeps the @. The idea is the same: display the smallest piece that does the job.

Misconception: A private variable keeps the data private

Students who remember private from Topic 3.8 think it protects users’ data. private controls which code can use a variable; it does not stop a person from reading a screen, copying a saved file, or selling a list. Privacy is about what the program collects, shows, keeps, and shares. Slide 9’s choice D and the Fair Question box after worksheet question 3 both target this.

Day 1 pause and try: the bus app

Show slide 9. Students commit to a letter on scrap paper or with fingers, then discuss. B is best: parents need to know where the bus is, not where each child is all day, and only while it runs its route. A collects more than needed and keeps it forever; C tracks children everywhere; D confuses private with privacy.

Day 1 · Direct instruction: Algorithmic bias

  1. Definition (4.1.B.1, slides 10–11). Algorithmic bias describes systemic and repeated errors in a program that create unfair outcomes for a specific group of users. Write the three parts on the board: systemic (built into the rules or the data, not chance), repeated (every time the situation comes up), a specific group. Contrast the two columns on slide 11: the ten-minute server crash lands on whoever was online; the name rule lands on the same people every time. The test is whether you can predict who will be harmed.
  2. Worked example (slide 12). Ask students to predict all four outputs before revealing. indexOf("-") is -1 only when there is no hyphen, so every hyphenated name is rejected. Ask: “Did it crash? Did it do what was written? Is it fair?” Check each of the three parts against the board. Ask for a fix: accept any name with length() >= 1.
  3. Demo NameCheck in the IDE: a different wrong assumption (every last name has at least three letters) rejects Ng and Li. Point to line 11 as the rule that causes it. Then run NameCheckFixed: all five names are accepted, and an empty entry would still be rejected.
  4. Why it hides (slide 13). If every test case looks like the programmer, a biased rule passes every test. Connect to testing from Topic 3.2: choose test cases from every group the program serves.

Misconception: The program just follows the rules, so it cannot be unfair

Students think a computer is automatically neutral. People wrote the rules and collected the data, and a program applies an unfair assumption to every user, faster and more consistently than any person could. The NameCheck demo makes this concrete: the program did exactly what it was told, and that was the problem.

Misconception: Any bug that hurts users is algorithmic bias

Students label every failure as bias. Run the three-part test from the board. A one-time crash or a typo in a help screen fails “systemic” or “a specific group”; it may be a reliability problem (Topic 3.2), but it is not bias.

Day 1 · Independent practice: Independent practice

Hand out the Handle With Care puzzle worksheet. Questions 1–5 are homework: tracing an email mask (question 1), which fields two apps need (question 2), the phone-mask snippet pool (question 3), the bias-versus-glitch face-off (question 4), and the first-name rule (question 5). Ask students to do the Think First box before question 2.

Teacher note

On question 1, watch for sam***@…: substring(0, 2) stops before index 2, so it is "sa". On question 5, the trace is the easy part; the answer key also asks students to explain why the rule is algorithmic bias using all three parts of the definition. Check that part when you collect it.

Day 1 · Closure: Glitch or bias?

Read two situations aloud and have students write “glitch” or “bias” on a sticky note, with one reason: (1) a quiz app crashes for everyone when the school Wi-Fi drops; (2) a voice assistant misunderstands users with one accent every time, because it learned mostly from recordings of other accents. Answers: glitch, then bias (systemic, repeated, one group). Collect the notes as a quick check.

Day 2 · Warm-up: Is this algorithmic bias?

Show SpaceCheck without running it. Students predict what happens to De La Cruz and Van Dyke, then say whether it is algorithmic bias and why. Run it: both are rejected because indexOf(" ") is not -1 when a name has a space. It is bias: the rule (systemic) rejects them every time (repeated), and always people whose family names have more than one word (a specific group). The fix is lastName.length() > 0. Today asks a new question: what if the problem is not in the rule but in the data?

Day 2 · Direct instruction: Collection method and bias

  1. Who did the data come from? (4.1.B.2, slides 14–15). Ask students to predict both outputs on slide 15 before revealing: 18 * 100 / 20 is 90 and 60 * 100 / 400 is 15. Same question, same code, same arithmetic; the only difference is who was asked. The collection method is how data was gathered: who, where, when, and how. Students at the bike rack are students who bike, so concluding that 90% of the school bikes extrapolates from a biased group to everyone.
  2. Demo SurveyGym and SurveyHomeroom: the same pattern with gym hours (90% from 40 students in the gym, 30% from 400 students in every homeroom). Ask students to name who the gym survey missed.
  3. More answers do not fix it (slide 16). Asking 2,000 students at the bike rack repeats the same tilt 2,000 times. Fix the method first: reach every kind of student.

Misconception: More responses means the data is accurate

Students trust a big number. Slide 16 is the counterexample: 2,000 answers from one kind of person versus 400 from everyone. Ask, “Who could this method never reach?” before “How many answered?”

Day 2 · Direct instruction: Incomplete and inaccurate data

  1. Slide 17. A student was absent for quiz 3, and the gradebook stored 0. The code is correct: 90 + 85 + 0 + 95 is 270, and 270 / 4 is 67. Leaving out the missing quiz gives 270 / 3, which is 90. Define incomplete (values missing) and inaccurate (values present but wrong, like 95 typed as 9). Either one can make a correct program give wrong results (4.1.B.3).
  2. Demo StepAverage: the dead-battery day recorded as 0 drags the average to 6520. Then StepAverageSkipMissing: when the tracker records -1, the if skips it and the average is 8150. Ask: “Why could the program skip -1 but not 0?” A missing value that looks exactly like a real one cannot be told apart; good data starts at collection.
  3. Inaccurate, not incomplete. Run StepAverageTypo after students predict: one value typed as 81000 instead of 8100 gives Average steps: 26375, more than three times the real average.
  4. Inefficient, too. A contact list with every person three times makes a reminder program send three messages to everyone: the program runs correctly but does three times the work.

Misconception: It ran without errors, so the result must be right

Students carry this over from Unit 1, where “no errors” was the finish line. Running without errors shows only that the code followed Java’s rules. Ask after every demo today: “Did it crash? Is the answer right?” StepAverage is the example: no error, wrong average.

Day 2 pause and try: what went wrong with the data?

Show slide 18. Pairs label each row biased collection, incomplete, or inaccurate. Answers: 1 biased collection (only people already in the library), 2 inaccurate (the value is there but wrong), 3 incomplete (readings are missing), 4 biased collection (a midnight poll reaches night owls). Point out that rows 1 and 4 are about who was reached, not about the values themselves.

Day 2 · Guided practice: Does this data set fit?

  1. Slides 19–20. Read the key sentence (4.1.C.1): a data set is gathered for a specific question and might not answer a different one. Pairs write yes, no, or not reliably for each bike-share question. Answers: 1 yes (station and time are recorded), 2 yes (every ride has a date), 3 no (people who never rent a bike never appear), 4 not reliably (a ride shows a rental, not enjoyment).
  2. Vary the question in time. Ask: “Could last year’s rides predict next year’s if the city doubles the number of stations?” Not reliably; the data was collected under different conditions, so extrapolating from it is risky.
  3. Students write one. Each pair writes one question this bike-share data can answer and one it can’t, and trades with another pair to judge.

Misconception: We already have data, so let's use it

Students start from the data they have instead of the question they are asking. Reverse the order: “What information would answer this question? Does this data set contain it?” If not, the honest answer is “we need different data.”

Day 2 · Independent practice: Independent practice

Puzzle worksheet questions 6–10 are homework: labeling data problems (question 6), the weather-station two truths and a lie (question 7), the step-tracker one-token fix (question 8), the cafeteria data fit (question 9), and who am I (question 10).

Teacher note

Question 8 uses static variables and a static method from Unit 3. The intended fix is steps != -1 on line 6; the key also accepts steps >= 0. If students change != to >, it prints the right numbers here but would skip a real day with 0 steps, which is worth discussing.

Day 2 · Closure: Closure and exit ticket

Spend one minute on slide 21 (vocabulary): point to a card and have a student give an example from the two days. Then slide 22: pairs pick an app they use and ask the five questions; cold-call one pair. Give the exit ticket (about five minutes). Question 1 checks safeguarding privacy (4.1.A), question 2 algorithmic bias and its link to how data was collected (4.1.B.1, 4.1.B.2), and question 3 incomplete data and whether a data set fits a question (4.1.B.3, 4.1.C.1). Re-teach the weakest one briefly before Topic 4.2.

Exit ticket

Question 1 · Multiple choice

A hypothetical app lets students prepay for school lunch with a gift card. Which design best safeguards users’ privacy?

  1. Print the full gift-card number on every receipt so students can check it.
  2. Save every student’s purchase history forever, in case it helps plan menus someday.
  3. Ask only for the student ID and card number, and show just the last four digits of the card on screen.
  4. Also ask for each student’s home address, but store it in a private instance variable.
Check your reasoning

C. It collects only what paying for lunch needs and shows only enough of the card number for the student to recognize it. A shows the whole number to anyone who sees the receipt. B keeps personal data far longer than needed, so the risk lasts for years. D collects an address the app does not need; private limits which code can use a variable, not which people can see the stored data.

Question 2 · Multiple choice

App X, a hypothetical map app, crashed for 20 minutes on Tuesday for everyone who was using it. App Y, a hypothetical voice assistant, misunderstands users with one particular accent every time they speak, because it learned from recordings made mostly by speakers of other accents. Which statement is correct?

  1. App X shows algorithmic bias, because its crash harmed every user who was online.
  2. App Y shows algorithmic bias: its errors repeat every time for one group of users, and they come from recordings that mostly left that group out.
  3. Neither app shows algorithmic bias, because a program follows the same instructions for every user.
  4. App Y shows algorithmic bias, and it must come from a programmer who wrote unfair rules into the code on purpose.
Check your reasoning

B. Algorithmic bias is a systemic, repeated error that is unfair to a specific group. App Y’s errors come from how it was built, happen every time, and hit users with one accent. The bias came from the data collection method: the recordings did not represent everyone who uses the app.

A confuses a bug with bias: App X’s crash happened once and hit whoever was online, so it is a reliability problem, not an error aimed at one group. C assumes following rules makes a program fair, but the same instructions trained on unrepresentative data give unfair results. D names the right app but the wrong cause: no one wrote an unfair rule; the bias came in with the recordings.

Question 3 · Multiple choice

A hypothetical tutoring center records each visit on a sign-in sheet: student name, date, and minutes stayed. Some students forgot to sign out, so their minutes were entered as 0. A correct program averages the minutes per visit. The principal also wants to use this data set to find out how much homework all students do at home. Which statement is correct?

  1. The data is complete, because every visit has a number in the minutes column, so the average is right and the data set can answer the homework question.
  2. The data is incomplete, but the average is still right, because the program adds and divides correctly.
  3. The data is incomplete, so the average is too low; once the 0s are fixed, the data set can answer the homework question, because it has many records.
  4. The data is incomplete, so the average is too low, and the data set cannot answer the homework question, because it measured visits to the center, not homework at home.
Check your reasoning

D. The real minutes are missing, and the 0s stand in for them, so the data is incomplete. The program adds each 0 as if it were a real visit, so the average comes out too low. The data set was gathered about visits to the tutoring center: students who never visit don’t appear, and minutes at the center are not minutes of homework at home.

A treats a 0 as a real value; a 0 entered for a missing sign-out is a missing value, not a measurement. B assumes correct code gives a correct result, but a correct program fed missing values still gives a wrong answer. C gets the data problem right but uses the data set because it is there: fixing the 0s does not change what it measured or who it left out.