Lots of people want to learn how to code… but what about teaching how to code?
Computer science educators for years have come up with concepts and activities for effectively teaching code. It’s a rich and often overlooked body of knowledge.
Take, for example, the PRIMM approach for structuring a coding exercise. This five-step acronym takes students from sizing up a piece of code, to modifying it, to finally writing some code of their own. Here’s how it works. I also include an interactive demo showing the approach in action.
The five steps of PRIMM
Predict
The exercise starts with showing the student a piece of code and asking them to predict what it will do, without actually running it.
Run
Now the student actually runs the code, and compares the results to their prediction.
Investigate
At this point, the student and instructor dig in on why the code resulted in the output. This could include activities such as extensive commenting, drawing flowcharts, and discussing questions about the code.
If the original code is returning errors, this is the time to debug and fix it. Students can do this together using pair programming.
Modify
At this point, students are asked to modify the working piece of code. This could be adding a progressive step or two to the code, or adding additonal error-checking capabilities.
Make
Now that students are comfortable debugging and then modifying the code, they will create a similar program from scratch.
From “Not mine” to “Mine”
PRIMM gradually walks students through the process by which code progresses from “not mine” to mine:
This process is common in life: code may be inherited from an older workflow or pasted from the internet, and the coder may need to debug it and/or modify it for some other purpose. PRIMM simulates this process in a classroom setting and encourages students to walk systematically through it.
Slides
See the below slides for a presentation-ready asset on teaching PRIMM in your workplace or learning organization.
Even if you aren’t interested in teaching others how to code, this exercise will give you an excellent framework for teaching yourself.
This slide deck is part of my resource library, which contains lesson plans, presentations and other assets for data education. For complete access, sign up below to my newsletter.
This download is part of my resource library. For exclusive free access, subscribe below.
Interactive demo: Teaching dplyr
with PRIMM
The below is an example of using the PRIMM method for teaching dplyr
using DataCamp DataCamp Light.
[insert page=’5771′ display=’content’]
Leave a Reply