dark mode light mode Search Menu

Teaching Efficiency

Paul Sableman on Flickr

Recently, I was working with some students on writing functions in JavaScript. The goal was to increase their program’s efficiency. However, when I started to talk about efficiency they really struggled with the “why”. I tried to explain that in the real world things aren’t so black and white and there isn’t just one right answer to a problem. There are many “right” answers. For the 7th graders I was working with, this seemed to open the floodgates and make them even more confused than before.

There are certain limits that any Computer Science teacher runs into when teaching concepts at a Middle School level. For my 7th grade students, writing functions and using computational abstraction are two tough concepts that pose a healthy challenge for them.

We start the year learning the basics of programming JavaScript using the turtle. The nice, neat lessons are concrete and allow students to gain confidence gradually. However, around mid-year I start to throw them some curveballs. Once we start to talk about efficiency, we learn programming concepts like control structures (loops, conditionals, etc) as well as functions and top-down design. While the turtle lessons are well suited for my greenhorn programmers, functions test the limits of their cognitive skills.

Some might even argue that 7th grade is too early for students to begin learning abstraction, although we have multiple sections of both algebra and geometry in our school. Developmentally, students are just beginning to learn how to unhinge from concrete ideas and manipulate ideas in their head. For the psychologist Jean Piaget, this stage of development is called the Formal Operational stage and he believed it starts around the age of 12 and lasts well into adulthood.

To return to my function writers from before, I realized I needed to start with something very concrete before moving up to big picture thinking. So, I started with a metaphor that anyone can understand, money. I told them a story about a young Mr McGuigan living off campus as a college undergrad. While the independence of off-campus life was exciting, there were some drawbacks. The long walk to school combined with a handful of 8 am classes being the foremost drawbacks.

However, being analytical in my thinking, I devised a plan to make myself more efficient in my commute. I charged myself a dollar for every minute it took me to walk to school. Now, no money was exchanged, but it was a way for me to conceptualize efficiency. My first day took me 27 minutes, so I charged myself $27. But, on the second day I found a shortcut through a park and a back entrance to my University building. This time my commute cost me $22 – a five-dollar gain. I went on to explain all the ways I cut corners to my students.

During this conversation, I was happy when students started asking questions like, “Why didn’t you ride a bike,” and “How about taking public transportation?” Now, they were starting to understand how abstraction can help us to solve problems. I explained that the bus would cost a flat $5 but would also reduce the amount of time it took me to get to school by 12 minutes – a worthy tradeoff.

Once they were comfortable with this model, I brought it back to our turtle programs we were writing. They could easily see that if they charged themselves $1 for every line of code, they incentivized themselves to be more efficient. We then began to talk about low-level functions and high-level functions that can help us to increase our efficiency – similar to taking public transit rather than walking.

This process of zooming in to the very concrete before zooming out to the big picture comes from a mental model I use often called the Ladder of Abstraction. Developed by linguist S.I. Hayakawa in 1939, the ladder describes how we can start from very concrete ideas and move up the ladder to abstract considerations. For older students, this slow, deliberate process can seem like oversimplification. However, for students just starting to manipulate abstract ideas in their heads, this process can give them a framework for something challenging.

Like math, some concepts in Computer Science can wade into deep waters rather quickly. I find it is important to take my lessons to the very concrete – like the commuting example I presented above. Once I feel that my students are grasping the very concrete ideas in front of them, I begin asking them “Why does this matter?” or “What’s the big picture here?” to get them moving back up the ladder. In the end, what they are practicing is the art of thinking abstractly to solve problems. In a world where there can be many right answers to a problem, finding a creative or efficient solution can make all the difference.

Learn More

Five Ways to Write Functions in Javascript


How to Write a Function in Javascript


Javascript Functions


Ladder of Abstraction

Java Control Structures


Control Structures in Java


Formal Operational Stage


Using Abstraction in the Classroom


Abstraction in Programming


OOP Concept Abstraction