How Do We Best Teach Programming to Beginners?
I’ve been thinking a lot lately about how I teach. I tend to take a “learn by doing” approach in my online courses where there are very clear, step-by-step instructions completed via video. However, this format gets pretty tough to execute in other contexts. For example, I teach an online graduate course for the University of Scranton, which is primarily text-based. This course’s goal is to get students with a healthcare background proficient in programming; the assumption is they are at least somewhat technical. After getting feedback, especially this semester, I’m realizing the approach my co-author and I took in creating the course was wrong. This got me thinking: how do we best teach programming to people who have never seen it?
Low Barrier to Entry
The first thing we need is a low barrier to entry. In the course, the very first assignment is a string sorter (take a list of strings and sort it alphabetically), which is difficult assignment for a few reasons:
- We should strive to make early assignments easy to describe in plain English, and sorting strings includes too many steps and edge cases. To sort strings, you compare 2 words by the first letter. If the first letters match, then look at the second letter, etc. But that’s not how any of us actually sort a list of string. We look at the whole list and sort it all at once.
- There are a lot of moving parts. Students now need to describe this problem in a way that can be converted into code, then figure out all the code they need to write. That means using pretty much all of the things programs have: variables, input via a file, control structures, methods, etc. This is a daunting task, especially for a beginner.
- We asked students to use Python via the Command Line. For students who don’t work with computers all the time (most are nurses), learning programming is hard enough. But now to use the CLI? That’s too much.
Not to mention, if the first assignment is difficult, a student’s confidence will go way down, and close them off to learning (if the first one is this hard, how can I possibly do anything more difficult?). So how can we lower that barrier when we teach programming?When we teach programming, we need to set a low barrier of entry by choosing the right tools for a beginner. Click To Tweet
Choosing the Right Tools
The first thing we can do is give them easier tools. I found a simple Python IDE called Thonny, where you install it and just write code. There’s a nice GUI that gives more useful feedback on errors. There’s also repl, which is an online IDE. No installation needed.
These 2 tools make it so students don’t need to worry about getting familiar with a new environment before learning a new skill. Imagine having to drive with your feet, in a different country, when you don’t even have your license.
Slowly Build Confidence
Once we have the right tools, it’s time to slowly build confidence. My new approach moving forward is this:
First, I give the students a primer on the programming language that outlines all the important syntax and ideas they’ll see. Variables, control structures, lists/arrays, methods, and more will all be important for students to write good programs. This primer should introduce and explain these ideas to them.
Next, I make sure they understand program logic without writing code. Their first assignment requires no code. I present them with a set of facts (written in English –
Bob is 31 years old – and code –
bob_age = 31;). Then I present them with statements in English and code (Bob is 27 year old /
27 == bob_age) and ask them to evaluate if the statement is true of false. Then I do the same thing with control structures – I will show them an if statement or a loop, ask them to evaluate it, and tell me the result (usually it’s something getting printed out on the screen).
This helps them build confidence because they are seeing how to take English and translate it to code, and vise versa. They are also learning how to read and understand code.Teach students how to read code before they write it by showing them a statement in their native language, then as a line of code. Click To Tweet
After that, it’s time for them to write their first (post-Hello World) program. I have them prompt the user with questions like, What is your name and How old are you. Then I have them store the answers and do something with them, like print out, “Hello, NAME” or, “In 20 years you will be (AGE + 20).”
This gets them comfortable writing code on a blank canvas, accepting input, and doing basic functions with the input.
Finally, I’ll have the do a Number Guessing Game. I love this assignment because you can easily build on it, adding complexity in the form of new control structures.
First, set a static number to guess and have the user add one guess. Then, make the number random and store it. Then, use a loop to have the user keep guessing until they get it right or run out of guesses.Make your programs easy to build on, conceptually. Present an easier solution, then make it more complex. Click To Tweet
In each assignment, I will also offer bonuses like, “in what instance would this statement be true?” For the user input program, students are to ask users what their job title is. A bonus for that assignment is to make that response grammatically correct (“You’re
a Programmer” vs. “You’re
an Olympic Diver”).
These are low pressure situations that get students thinking outside the box, which should ultimately make them more comfortable with critical thinking on top of this, “I need code that does X.”Bonuses are low-risk for students that help them critically think beyond what the assignment asks of them. Click To Tweet
Testing the Waters
I just rolled out this new method in my course, and I’m excited to see the results. I tried to forget all assumptions because I’ve been coding for near 15 years. I will be interested to hear feedback and see student progress.