Cognitive Load and Coding

I bought The Cambridge Handbook for Computing Education Research a few months ago but it is only over the last few weeks that I have had the time and state of mind to properly sink my teeth into some of its contents. It is divided into dozens of interesting chapters that focus on a wide range of computational areas. One of the chapters in the book – Cognitive Sciences for Computing Education – explores the deeper layers of neuroscience behind how memory works in a learner setting and how it gets exhibited in student behaviour. From a computational context, the chapter goes on to document good examples of what research says about how students learn what they learn. It also dives deep into areas of knowledge retention and why it is important for teachers to train students in understanding how to notice commonalities between problems they know how to solve and a new problem. The entire chapter is filled with lots of different areas of research that address both classroom pedagogy and the biology of how the brain functions. However, for the purposes of this post, I wish to document some key takeaways from my readings around this rather broader topic/question.

What are some features of an optimal cognitive load when students are learning to code?


What is cognitive load?

Before we go further on this issue, let us be clear about what we mean by cognitive load and why an optimal level is required for it.

Much like a computer’s primary memory, cognitive load is the amount of processing a person’s working memory is doing at any given time. The more optimal and manageable this is, the better chances exist that contents will be moved to long term memory for storage and retrieval. If, however, levels go beyond the optimal limits, then new information processing is affected. All of this depends on how complex the material and instructional design being worked with is. In short, minimize extraneous load and maximize germane load by effectively managing intrinsic load.

One important thing to note, however, is even though the loads seem like independent areas inside us, they are not. Germane cognitive load – the area which deeply associates new with existing knowledge/learning – behaves in reaction to how intrinsic and extrinsic loads are behaving. So in a programming setting, if a concept like recursion is being introduced and the lesson has more elements which simplify (by intentional association with previous learning or by chunking information into small units) new knowledge – either by creating parallels to looping structures or by focusing on how function calls are managed within memory stack – then there are less things to do for extrinsic load. So, students spend more time seeing patterns of loops (covered already in previous lessons) within recursive algorithms and may even try to write programs originally written using loops as recursive calls instead. This then can deepen their knowledge on loops while associating similar elements with recursion.

Cognitive loads in computing education

I will now document a few interesting sources that discuss management of optimal cognitive loads for coding. First, let us start with the book itself. The chapter on cognitive sciences documents research findings in three key areas that were used to reduce cognitive loads work within computing.

  • Worked examples
    The deciding factor in how effective usage of worked examples were in some classrooms was the student’s self explanation skills. Some studies observed that students who were given partially completed solutions performed much better post-completion than those who had a completed example and had to start from scratch. Other studies saw a reduction in time spent on partially solved problems but more data is needed from classrooms to clearly identify benefits of these.
  • Subgoals (labelled interventions)
    This intervention technique, seen in STEM fields, is a way to decompose the problem into smaller, more identifiable and labelled units, so students can better recognize the structural patterns. Several studies have indicated that students are able to better manage cognitive loads when subgoals and user-created labels are included as part of the problem solving process. Too little or too much instructional support, interestingly, had the same poor learner outcome. So, self-explaining/constructive subgoal labels with some instructional support/hints seemed to have the most effective outcomes in code learners.
  • Parsons’ question format
    The Parson’s question format is a fragmented collection of code blocks which need to be organized according to the proper structure of the final solution for a program. An example of this could look something like this.
Source
https://cseducators.stackexchange.com/questions/302/effectiveness-of-parsons-problems

Students then re-organize the blocks by using their existing knowledge and finalize the solution. This approach has shown effective results in helping learners maintain low cognitive loads (since the solution components are already available and no syntax errors are possible, this method helps in reduction of extraneous cognitive loads) and ensure student focus is more on the semantics of the statements. The Runestone Academy is a good example of such interactive elements in their online books for various programming languages.


A research paper from Ritsumeikan University in Japan, that was published in the International Journal of Electrical and Computer Engineering, documents ways in which cognitive loads can be predicted in learners of computer programming skills based on their behavior. The key takeaways from it are as follows:

  • Schema – the process of organizing content within Germane Cognitive Load – is a critical factor when trying to predict cognitive loads in learners. Having students continuously work on similar programs – such as code that utilizes selection/iteration statements in various ways – allows for them to better structure the concepts when new/unknown challenges (such as a sorting algorithm) are presented.
  • It is often hard to predict how much of an extraneous load is being applied by the student because each student has a unique working memory capacity. Coupling this with their previous knowledge of the concept (even from other subjects, such as linear algebra or unit conversion) can impact how well they respond to something new in programming.
  • Self-assessment by students on their own learning (via reflections and other forms of feedback) is critical for teachers to adjust future lessons.

Another 2016 paper written for the Cognitive Science Society, uses categories of different programming activities to see how using sub-goals and self-explanation impacts students of programming.

Using Subgoal Learning and Self-Explanation to Improve Programming Education
, Jan 2016

The paper has a lot of useful details on the methodologies used in highlighting instructional support for students. Usage of sub-goals and allowing students self-explanation in their work was measured using App Inventor’s interface. The takeaways from this paper were quite interesting.

  • The constructive methods of learning subgoals came out as the most effective one but given the right amount of instructional support.
  • Getting feedback on constructed labels or getting hints on constructing labels achieved best performance – but not both.
  • Students who got hints while constructing labels created higher quality work than those who did not. Feedback seemed to decrease these students’ performances.
  • When students did not get hints, then feedback became a critical piece in improving their performance.
  • In summary, some sort of support structure that linked current and previous knowledge, in moderation, created higher quality performance from students.

The final reading I wish to document comes from Philip Sands, a Ph.D. candidate at Michigan State University who specializes in Educational Psychology and Educational Technology. His 2019 piece, “Addressing Cognitive Load in the Computer Science classroom”, further explores the different methods teachers can employ in their classrooms to help students work better with introductory coding. The summary of the strategies he suggests is given below.

“Addressing Cognitive Load in the Computer Science Classroom”, Sands (2019)

The method I wish to focus on here is the live-coded modeling since I have seen this work effectively in my classrooms. When I was introducing new concepts – or even extensions to concepts already covered in the classroom – then starting with a blank canvas on the IDE, setting up the comments to create a mindmap, and then slowly starting the work on the code (with good internal documentation) had a big impact on how students processed the various complexities and details of the code later. These interactive sessions, where I am the one coding and students are viewers to the process of creating a complete solution (while perhaps also taking notes) became a good model for them to emulate when they started working independently on challenges/assignments. This ensured that stress levels were more manageable and a guide existed in how to break down a bigger problem into smaller problems – a key element to cognitive load reduction in coding. This also ensured that when they did encounter problems they knew exactly where it was and what needed to be done (even if they did not know how) to resolve it.

Summary

  • Regardless of which intervention/approach you wish to try in your coding class, ensuring a bridge, a link, that connects previous knowledge to new information is critical. These may take many forms but need to exist at every stage of the lesson so that cognitive loads can be maintained at optimal levels.
  • The nature of the programming language also matters. With interventions like Parsons, the block based approach (such as Scratch) may assist in aiding students feel less stressed about syntax than a more layered language, such as Java. Python, as a text based option, has gained understandable popularity with novice and experienced programmers alike for its simplicity in structure.
  • Methods like pair programming and tiered lessons or unplugged activities can further create the suitable support structures for students to better manage cognitive loads when working with new or complex programming constructs. Teacher led live coding models also help in creating a structure for students to follow when learning how to code.
  • Feedback is a critical piece of the load equation since this too can take many forms. This includes getting feedback on a lesson and giving feedback on student work. Making changes to the lessons (including flipped instruction and other differentiated methods) so that every student is working with manageable levels of intrinsic memory needs to be a constant feature in the classroom.

Further recommended reading