Saturday 9 April 2016

What is it about coding?

It seems very fashionable current to teach coding to school students. When I ask my colleagues why I am often met with rehearsed responses and very little real consideration. The response seems to be because our jobs are being taken by robots and there is typically some anecdotal story about the disruptive technologies. These are entertaining, and mostly true but what I feel is missing is:


"What is it about coding that is particularly important and powerful"

and perhaps more importantly


"WHAT do we really want students to learn?"

There are many technologies to help teachers using coding in classrooms. They are amazing and the students love them; Scratch, Python, Raspberry Pi, Arduino, Code Dojo, Code.Org and so many more. A teacher could use any of these technologies to tick the 'coding' box. Each seems to have some benefits but let us look past the particular technology or brands to the underlying skills so we can do more than just satisfy a current trend but truly provide transformational learning.

These are the 6 aspects to coding which I believe are most valuable to our students:

1) Deconstruct problems
I heard it put well by a senior teacher recently;

"No matter the future a skill we need students to have is problem solving skills".

A fundamental aspect of problem solving is being able to break a problem into a set of smaller tasks.



If a student wants to develop an interactive game the students will need to solve a series of problems. How to maps keys for the interaction?
How to 'draw' the character, and the background?
How will the character image changes as buttons are pressed?
Should both the image and location of the image change?

Each solution will lead to more considerations, but through these the real learning happens.

Problem deconstruction is a great skill for students to develop. It demonstrates understanding of the original problem and allows team members to operate independently towards the same goal. It will doubtlessly arise in future careers and personal situations and it is fundamental skills to coding.

The problem is it can be a difficult skill to teach. Modelling provides some benefit but the more experience students get solving complex problems with coding the more they will practise deconstructing problems.

2) Algorithmic thinking

One of the greatest demonstrations of understanding is generalisation. Looking at activities through algorithmic thinking provides clear abstract generalisation. Sure A student can repeat the teacher's facts or a skill they have been shown repeatedly. Real understanding comes when they can write a set of instructions which take any input and complete the task

Perhaps a mathematical example of this is using code to draw a Koch Snowflake.



This is where we take a triangle and on each side we add a triangle with a side length a third of the original. We now have a 6 pointed star, then again add a triangle to each side (again with each side a third of the existing side). This process can be repeated to infinity.

For students to draw this image, they only need to start with a simple triangle.

Then instead of drawing a side with length of 1 unit, they can draw a four line segments each with a length of a third. The first is along the side and then they turn 60 degrees out, move the next segment, then move back in (after a 120 degree turn in) finally they complete the last third of the triangle's side. This process is then repeated.  

An example of some code that can do this is below. As the learner develops this (or similar) code they develop their deeper understanding of the concept. 



3) Range of strategies to solve issues

When different students encounters a problem they may seek to resolve it using different approaches. In my classroom I see this when I use the "think, pair, share" approach to solving problems. Let the student attempt themselves. Once they have tried their best then they see how a different student approached it. They may find their peer started at a completed different point. (I consider this similar to De Bono's Parallel Thinking.)

Finally we can compare the approaches around the class. Without exception a student will always surprise me with a novel (even if incorrect) approach.

This variety of approach is vital when creating solutions with coding. Student may choose to use a "For Loop", or a "While Loop" for different reasons. Some students want to finish quickly while others want the perfect answer. Some focus on procedures using lots of code, others try to use lots of functions to reduce the procedural coding. All approaches have benefits in particular aspects, but no single approach is always perfect.

Students need to develop flexibility in their problem solving to avoid reliance on a single strategy. This is one of coding's most powerful and important aspects. There is always a different way to code the solution and this flows into the next point, learning from the approach of others.

4) Learn from others

The most common strategy I see in solving problems is also one of the best. If a student is finding something difficult, they look to see what others are doing. In coding this is no different. If I want to change the type of variable I am working with, I can look at someone else's code to see how they did it. If I know what I want to do, but don't know the syntax or function to do it, I just compare to the work of others.

In old educational vocabulary this was plagiarism in new world this is called open source.

However really learning from the work of others is not as easy as we think. The students need to deconstruct and understand the work of others, then map this to their own work. Rarely is this as simple as cut and paste without additional editing and  substantial testing.

Additionally finding goods examples can be difficult in the first place. Searching really requires the student to be able to articulate what the precise problem is. Sites like GitHub and Instructables provide a lot of examples for students to compare to and explore, and sometimes they find a solution to a problem they didn't even know existed.

5) Documentation importance

Often through seeing the examples of others, students see how important it is to have clear and concise comments in code. Although some students then forget to include comments in their own code, they then get to experience the challenges in the debugging and optimisation processes.

When students start producing simple programs, they feel like they will remember what each line does. Once the program gets to around 40 lines of code, it starts to get a little harder, and once program is over 100 lines (and far beyond) there is often variables, lines or even entire functions which have purposes that are forgotten.





Using documentation (including comments and variable names) well makes the coding much easier and debugging quicker and more effective.

I suggest students work on at least 1 team programming project to experience the benefits and reliance on well described code. As the Association for Computer Machinery suggest, "Comments are more important than code" having spent many hours of my life trying to fix code (often my own) I tend to agree.

6) Tuning solutions

We have developed the paradigm in education to focus on completing a solution, be it in a test or submitting assignments.

"You need to submit your final assignment to me by Friday"
-me, more times than I like to admit

The paradigm is different with coding. The process doesn't end at the code 'working'. There is often testing, optimisation and additions once the code is broadly working. Even when the code is fully functional, a new technology appears and more testing is needed.

How will education system change the incorporate continuously improving coded solutions? I am not sure, but if we want to push coding continuous improvement will likely be part of it.

Perhaps in the future I will be marking a student assignment, and a dialogue box will appear saying, "An update is available for this document. Download now?"


In my opinion, these 6 skills are the underlying reasons why we should teach coding. Knowing these should take the emphasis off learning the syntax of a certain language or quirks of a single technology. (Noting some level of understanding syntax is needed, in the same way some level of test techniques is needed, but they are not the focus)

I would be keen to hear what others see as the underlying reasons for teaching code. Please let me know either in the comments below, or tweet me @jarradstrain.