Teach Object Oriented Programming concepts to second graders

What is Object Oriented Programming (OOP) and why should I take valuable class time to teach it? Well, it’s a programming paradigm used to store and relate different things that all match a template, that is, are structured in the same way. That template is called a class and each member or instance of a class is an object. So I might have a book class, which says that every book would have a title, an author, a year published, and so on, but each individual book (object) would have different values for each of those data fields. That’s the meaning of “structured data”. You, a computer, or a student, can perform the same operation on each book in a shelf (like checking if the title is Moby Dick) and then move on to the next one, all systematically.

This post isn’t quite a lesson plan, but it’s a fairly detailed outline on which to base one. I’m going to list the lesson objectives now to persuade you to keep reading. After the lesson students will be able to: understand the nature structured data from a template, compile data into a fixed structure, compare and contrast between members of a category, devise a procedure to access structured data, and consistently follow that procedure. In comp sci terms, students will devise an algorithm involving a loop containing a conditional branching based on elements in an array. This means that students will go through a bunch of similar items and make a decision based on the differences between them. As a teacher, you can use this exercise as a lead-in to reading tables of information. It’s the same idea: each entry (object) has different values for the same properties.

This activity is computer science without computers, a methodology I’m going to christen paper programming. Such, no experience with or access to computers is necessary. Instead, you’ll need basic art supplies: construction paper, markers, scissors, so on.  You’ll need about an hour or two (you can break it up) and enough space to line up all your students.

Here’s the neat part: any category can be made into a class, so the actual content of the lesson can be chosen to fit your curriculum. I’m going to continue using books, but you could use countries, U.S. presidents, or space misions. Assign each student a member of the category, which they should represent artistically on something they can easily hold. Get creative: use country flags or rocket outlines, as long as you can write on top of it, or tape notebook paper on the other side. Make it tangible; the point is to make the object a physical…object.

So far, this could be an ordinary book report. Here’s where the structured data comes in. Instead of “Moby Dick was written by Herman Melville and published in 1851…”, students will write:

Title: Moby Dick
Author: Herman Melville
Published: 1851

The label left of the colon is the data field, and every object in the same class shares the same ones. To that end, write a list of data fields relevant to the category of things you’ve chosen on the board. Fill out the fields with example data on the board, but emphasize that this list (the class) is just a template. There’s not a real book called Title written by Author. Getting students to understand this abstraction could be the hardest part of the lesson. It might help to compare objects to worksheets, where each student fills out his or her name in a standard blank. (In fact, when you grade worksheets, you engage in a repetitive process similar to the one your students are about to do!)

But don’t let that discourage you. Repetitive does not mean useless or uncreative, especially when a computer is doing the work. Here’s how the lesson proper works. Line up all the students, each holding his or her object. One student gets to be special, and I’ll borrow a phrase from my CS professor and call him or her the Wizard of the OS, as in operating system (what did you think it meant?). The Wizard walks down the line, stopping at each student, and does some sort of processing. Possible processing tasks include: how many books in the list were written by a certain author, how many were written after a certain year, which was written most recently, which title comes first alphabetically, and so on. The Wizard must follow clear instructions written ahead of time of what to do with each object. He or she is only allowed to “remember” or record information specified in advance, like a running total or which object is best meets the criteria out of those examined thus far. For example, to find the book written first, ask the book for its year published, and if it’s less than the previous lowest, have that book step forward and the previous lowest step back into line, then go on to the next one. The objects can’t talk to each other and can only respond the questions the Wizard asks. I recommend writing one algorithm with the class on the board, working it out (maybe you’re the Wizard, maybe not), and then breaking up into groups, each assigned a different task. Reassemble and have one student not from the group that wrote the algorithm be the Wizard. That way he or she can’t “fill in the gaps” and must perform only the actions written down. This will likely cause some only-now obvious errors in logic, so expect hilarity to ensue.

When you’re done, collect the objects (which the students have put their name on) and grade them based on the ability to put (only) the right information in each data field. You can also grade the factual accuracy. If you discover an error during the lesson that disrupts the activity, you could use it to highlight the importance of filling out the data fields correctly (computer’s can’t improvise!). Errors can be as seemingly benign as listing “America” in some places and “United States” in others, which the computer will (and Wizard should) interpret as separate. If it’s a more serious error, you risk stigmatizing the student. One way around that is to have each student hold someone else’s object, further emphasizing that they are interchangeable and preventing reading between the lines.

Just as OOP is structure to hold whatever type of data you like, this plan for a lesson plan is a structure to teach whatever content you like. There are a lot of different variations I’ve pointed out, which you can adapt to meet your teaching style, curriculum, and student level. Have fun, learn a lot, and tell me how it goes! (Legal: This text, as always, is released under CC-BY Max Goldstein, but the ideas are free to use.)

Advertisements

One response to this post.

  1. This piece of writing provides clear idea for the new visitors of blogging, that
    actually how to do blogging and site-building.

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: