Lesson for Abstraction AND Algorithms?

Hi All,

I don’t know where to put this, maybe under AP Test Prep, or unit 5?? BUT reflecting on the create this year, I felt like students still weren’t getting this idea about abstraction. They seemed to get it in unit 3, but come the AP task time, they had forgotten why they would make separate algorithms and use abstraction.

SO… I was thinking of adding a lesson. There is a classic CS lesson that has a teacher act as a computer while individuals give “computer-like” directions but the teacher takes the directions VERY literally (much like a computer). Usually this is one of the first lessons a CS student might have, BUT, I was thinking you could do it in Unit 5 or before the AP test to talk about the need for separate algorithms and using abstraction. Here’s the big idea:

  1. Do the activity: https://www.youtube.com/watch?v=XWe4iohhmIw

  2. Ask students - if I wanted to make a peanut butter and banana sandwhich, how would this algorithm be the same, how would it be different? What about a nutella and banana, or even a ham/mayo sandwhich? Most of it is going to be the same, but there are small parts that need to be tweaked.

  3. Have students break up their large PB&J algorithm into sub-algorithms that would be useful (opening jars, spreading peanut butter, spreading jelly, spreading mayo, opening bread, applying lunch meats, etc.). This gets at the “algorithm” component of the AP Task.

  4. Look for ways to “manage complexity” by writing one function that has a parameter of “spreadableIngredient” that allows you to write one function for spreading mayo, PB, jelly, nutella, honey, etc. This could be an example of abstraction as needed for the AP task.

SO… that’s the big idea. I am interested in your feedback. What am I missing? What could be added? Does this help students? Confuse students? Where do I find “sunflower seed butter” really cheap? :slight_smile:

I feel like we talk about each of these things through out the year, but I need to have a common experience to anchor students’ thinking “just in time” for the task. I think this might have legs.

I’ll tag some others in here too just so it get’s seen :wink: @terence.stone25 @frank_w_lee @hwalden @karenma


Hey @kaitie_o_bryan!

I think it’s a great idea to make a “practice Create PT” using real-life analogies to help students ground these ideas in more familiar contexts.

A key factor that’s brought out in this activity is a relevant and authentic need to manage complexity (when students are asked to make different types of sandwiches). I think that’s also done well in the actual programming levels of the code.org curriculum (with the turtle and drawing the underwater scene), but this activity might give extra reinforcement of the ideas in parallel for students who are overwhelmed or still have anxiety over programming - it tells them these ideas aren’t “programming concepts”, but rather general problem-solving ideas/strategies that we can also implement through programming.

An issue my students had (in addition to having trouble identifying “abstraction-able” portions of their project) was thinking of a project that had the “right” amount of complexity that allowed them to have a parent-child-child algorithm.

This analogy could be used as an example of how you can scale up or down the level of abstraction. As you stated, there could be a need to make a function for spreading any ingredient. If this isn’t complex enough, we can scale up and think how this would fit into a larger context, say packing a sack lunch, and what other functions might be useful? Ex: parent algorithm is packLunch and two children: makeSandwich(type) and packSnack. Or have students think of what are other functions (child algorithms) they can add to makeSandwich? (Ex: spread(ingredient), addMeat(meat), addCheese(cheese), pickBread(bread))

If time is an issue, I would probably just have students write algorithms for the other sandwiches without actually building the sandwiches - which would save us the trouble of buying sunflower seed butter :slight_smile:


I like the idea of revisiting this activity before the Create Task, @kaitie_o_bryan. At this point, students are pretty entrenched in the magic of onEvents, and sometimes forget the concepts that were taught in Unit 3.

If I were to do a similar activity right before the CT, I’d want to make sure that we connect from unplugged back to plugged. So after we did the activity as stated, I would reinforce the concept with an example in Javascript. This would give the students a touchpoint to refer back to when working on their own projects.

1 Like

SunButter at Wallyworld for $6.