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
- Goals (slide 3). Read the five goals; the first two are today’s, the last three are Day 2’s.
- 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.
- 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.
- 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
- Trace slide 8. The card number has 16 characters, so
card.length() - 4is 12, andsubstring(12)returns"6677". Ask: “Whycard.length() - 4instead of typing 12?” It works for numbers of any length. - Demo
MaskPhonethenMaskPhoneFixedin 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. - Vary the data. Show
MaskEmailand ask students to predict the output before running it:Code sent to j***@example.com.indexOf("@")is 10, andsubstring(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
- 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.
- 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 withlength() >= 1. - Demo
NameCheckin the IDE: a different wrong assumption (every last name has at least three letters) rejectsNgandLi. Point to line 11 as the rule that causes it. Then runNameCheckFixed: all five names are accepted, and an empty entry would still be rejected. - 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
- 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 / 20is 90 and60 * 100 / 400is 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. - Demo
SurveyGymandSurveyHomeroom: 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. - 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
- 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).
- Demo
StepAverage: the dead-battery day recorded as 0 drags the average to 6520. ThenStepAverageSkipMissing: when the tracker records -1, theifskips 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. - Inaccurate, not incomplete. Run
StepAverageTypoafter students predict: one value typed as 81000 instead of 8100 givesAverage steps: 26375, more than three times the real average. - 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?
- 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).
- 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.
- 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.