Coding Strategies - Code Tracing
It is common practice to teach children to read before they learn to write. So why is it that, when teaching them to code, we often get children to write code before they can read it?
Code tracing is a well-established approach designed to help children with code comprehension. Similar to strategies often used for teaching reading and writing, code tracing requires learners to read, understand and analyse code before learning to write code for themselves.
How it works
Start by giving students some sample code to read before asking them to predict the outcome; this should preferably be done away from the computer so that the students focus on reading the code rather than executing it.
Next, instruct the students to step through the code, line-by-line, and record the expected behaviour (or outcomes) and execution flow (see example below).
Code tracing is a well-established approach designed to help children with code comprehension. Similar to strategies often used for teaching reading and writing, code tracing requires learners to read, understand and analyse code before learning to write code for themselves.
How it works
Start by giving students some sample code to read before asking them to predict the outcome; this should preferably be done away from the computer so that the students focus on reading the code rather than executing it.
Next, instruct the students to step through the code, line-by-line, and record the expected behaviour (or outcomes) and execution flow (see example below).
Code tracing example (Python)
Taking it further
Once the students have successfully traced the given problem, challenge them to create their own solution using the traced example.
Once the students have successfully traced the given problem, challenge them to create their own solution using the traced example.