FEATURE
n Learning to write code can be a challenge for students, but there are evidence-based approaches to support them
Credit: Stock.adobe.com/Gorodenkoff
HOW TO SUPPORT YOUR STUDENTS TO WRITE CODE Will Grey shares some evidence-based approaches for teaching students to write code
or many children, writing code can be a daunting prospect. To help our students learn to write code, we can use a range of scaffolded pedagogies. Initially, these approaches take ownership of the code away from the students, giving them confidence to explore and experiment. Gradually, as the students gain confidence, we can reduce the amount of support until they are able to write their own programs independently. On page 70 of this special edition, I shared approaches to support pupils learning to read code. These included activities such as explaining, predicting, and tracing code, as well as live demonstrations with worked examples. Now, I’ll share some evidence-based approaches to support pupils who are learning to write their own code.
F
82
The Big Book of Computing Pedagogy
Fixing broken code
Children can find and fix common syntax, runtime, and logical errors in a piece of code. These errors might include missing brackets, missing speech marks, spelling mistakes, or missing variable declarations. Pupils can use the programming language’s translator to help find the errors by making the fixes and then running the code to test that it works. Pupils will need to be made aware of how the errors present themselves – this is unique to each translator and language and is not always obvious. For instance, in the default IDLE Python interpreter, it can be unclear where each error is located. Once pupils are familiar with a variety of common error messages, their causes, and how to fix them, they will be able to debug their own code with greater confidence
and resilience. For extra challenge, debugging exercises can be carried out on paper, where there is no feedback from the translator.
Completion problems and pseudocode We can give children partial solutions to complete. This has scope for a variety of levels of differentiation: as students progress, we can gradually leave out more code. Initially, students might be given most of the code but with parts of some statements missing. Then, we might remove statements completely. Next, we could remove several lines or complete blocks of code. Finally, we could remove all code and only provide comments to the pupils. If these comments are detailed enough, then this is like converting from pseudocode into working code.