Technology and Computer Science Computer Science
Events and Buttons: How Apps Respond to Clicks
Students read how apps wait for events, trace a pseudocode counter app and a quiz app through a series of taps, and design the handlers for a simple timer app.
THE GOAL
What students will learn
Students will explain event-driven programming, trace what happens when a user triggers events in a simple pseudocode app, predict the state of variables after a sequence of events, and design the event handlers for a small app of their own.
BEFORE THE BELL
Get ready
Copy the 3-page worksheet (one per student). No computers needed.
KEEP THE PLAN CLOSE
Your teacher guide
Teacher directions only. Student worksheets and the answer key are in the complete PDF.
SubstitutePlans.com
Technology and Computer Science • Computer Science
SP-CS-020 • Free to print and use in your classroom • substituteplans.com
Events and Buttons: How Apps Respond to Clicks
Technology and Computer Science • Computer Science • Grades 7-9 • 45 minutes
Time needed: 45 minutes (one class period)
Prep: Copy the 3-page worksheet (one per student). No computers needed.
Technology: None.
Student independence: High. Individual reading, tracing and design.
Copies to make: One 3-page worksheet per student
Materials: Pencils, Worksheet
Goal for today: Students will explain event-driven programming, trace what happens when a user triggers events in a simple pseudocode app, predict the state of variables after a sequence of events, and design the event handlers for a small app of their own.
BEFORE THE BELL
☐ Copy the worksheet, one per student (3 pages).
☐ Write on the board: EVENT = something that happens (a tap, a key press, a timer tick). HANDLER = the code that runs when that event happens.
☐ Write: An app does nothing until an event happens. Then it runs the handler and goes back to waiting.
SAY THIS TO START
A recipe runs top to bottom. An app does not. An app sits and waits, and when you tap something it runs a small chunk of code and goes back to waiting. That chunk is called an event handler. Today you will trace two small apps written in plain-English code, predict exactly what they do after each tap, and then design the handlers for an app of your own.
RUN OF SHOW
0–5 min - YOU: Take attendance. Hand out the worksheet and read the definitions on the board.
STUDENTS: Follow along.
5–13 min - YOU: Students read page 1 and the counter app.
STUDENTS: Read the explanation and the first app.
13–25 min - YOU: Students complete Part A (counter traces). Walk the room; check that they update the variable before the label.
STUDENTS: Trace the counter app.
25–36 min - YOU: Students complete Part B (quiz app).
STUDENTS: Trace the quiz app.
36–43 min - YOU: Students complete Part C (design the timer app).
STUDENTS: Write handlers in pseudocode.
43–45 min - YOU: Collect worksheets.
STUDENTS: Hand in the worksheet.
IF THINGS GO WRONG
• If students run the handlers in the order they are written instead of the order the events happen, remind them: nothing runs until its event fires.
• If students forget that a variable keeps its value between events, have them write the variable's value in the margin after every tap.
• If a student finishes early, use the early finisher list.
EARLY FINISHERS
• Add a Reset button to the counter app and write its handler. What should the label show afterward?
• Find a bug: in the quiz app, what happens if the user taps Next before answering? Write a fix.
SUPPORT AND CHALLENGE
• Support: Give students a table with a row per tap and columns for each variable, and skip item 10.
• Challenge: Ask students to add a "best score" variable to the quiz app that survives tapping Restart, and write every handler change needed.
NOTES FOR THE TEACHER (you fill this in)
How far the class got / what to pick up next:
Students who were especially helpful:
Anything the teacher should know:
The complete PDF has the student worksheet (pages 4-6) and the answer key (page 7).