Unplugged Activity: Events and Handlers

Teacher Note

An unplugged activity is an activity that takes place away from the computer - in other words, “unplugged” from a device. This course introduces new concepts in a fun way that gets kids up and moving, often reacting and interacting with other students face-to-face while playing a game or completing a challenge. Unplugged activities allow kids to practice concepts away from the computer so that when they move to activities on the computer, they have already walked through and thought about the concepts on their own.

Objective

To reinforce the event-driven programming model by acting out events and the resulting actions encapsulated by an event handler.

Overview

Identify one-third of the class to be the “Events” and the rest of the class to be the “Event Handlers.”

For the “Event” students, have each student come up with an event to model. Students should invent their own events, but some examples could be:

  • Door opens
  • Lights turn off
  • Hands clap twice
  • Both hands raised

After deciding on an event, each student should write down their event twice, on two different index cards. All of the cards should be shuffled and passed out to the “Event Handler” students.

When the “Event Handler” students have received their assigned events, each student should come up with some sort of action to take based on their event. Students should invent their own actions, but some examples could be:

  • Door opens –> Walk outside
  • Lights turn off –> Go to sleep
  • Hands clap twice –> Stomp feet three times
  • Both hands raised –> Say “Touchdown!”

Line up the “Event” students at the front of the classroom, and have each one perform their event. When the event is performed, the associated “Event Handler” students for that event should also perform the subsequent action.

After all the events and event handlers have been called, you can randomly call on different “Event” students to perform, and trigger different event handlers – you can speed this up and see if the students react quickly to their assigned event.

Materials

  • Index cards
  • Pens or pencils

Rules

  • Unless instructed otherwise, students do not speak or make noise during this activity unless it is part of their event or action.
  • Students should be aware of the activities of the other people in the classroom but cannot tell other students what to do.

Reflections

Have a discussion about how that felt/worked:

  • Were there any programming errors or bugs in the system? Did a student miss handling an event?
  • What was it like to keep track of the different events going on?
  • Sometimes there was more than one event handler for a given event… how does that work?
  • Could there be one event handler for multiple events? (yes)
  • Could an event handler also trigger an event? (yes) If so, how would that work? (Lights turn off –> Go to sleep –> Teacher says, “Wake up!”)

Computer Programming Connection

A computer program is a set of instructions telling the computer how to process input and deliver output. An important part of programming is telling the computer WHEN to perform a certain task. Events are a way to trigger certain instructions.