#HigherCS
Programming: Teaching Standard Algorithms - Peter Donaldson
Visualising Hidden Mechanisms
Lots of hidden mechanisms in Computing. If pupils do not have an understanding of these mechanisms (only seen examples or relying on intuition) they will struggle. Showing examples is not enough. Must have a causal model or there can be "random twiddling" to try and fix problems. Watching a process helps but it is not enough. Often programming gives too much work for eyes and not enough work for the brain. You don't have to be a genius to program, you just have to develop an understanding of what the computer does when it is given an instruction.
How do we do that currently? Diagrams e.g. Boxes for variables or use debugger to inspect variables and trace an execution of a program. Use actual boxes and get pupils to put things in the boxes. (An aside was how do you read an assignment statement? Not read left to right or how do you make sense of total = total + 1?) interactively model the process of writing code - start with a blank page and build the code up a line at a time rather than starting with example programs.
Other suggeststions: draw a flowchart of a program; draw structure diagram; trace table/debugging tools; step through program and asking "what happens next...". There are limitations of all these approaches. Each approach contributes something but often need to teach new ways of describing when they are still getting their heads round coding. Is the cart before the horse teaching design notation before they understand coding?
Example was given of using a paper table to trace through a program. Started by identifying expressions (i.e. something that generates a value).
Teachers answer was:
Next draw arrows to show the flow of control:
Finally, hand execute the program with the input 20, 7, -1 (put the step numbers beside the arrows - makes it easier to see when things happen). Fill in changing variables in a table and show the expression being evaluated at each stage too. Work in progress:
So our final trace looked like this:
Using the "Expression evaluator" box makes pupils' understanding of what is going on clear.
But research shows there is a strong correlation between the ability to trace the flow of a program and the ability to produce code.
No comments:
Post a Comment