In 1988, a psychologist in Sydney argued that solving problems is an inefficient way to learn how to solve them.
Every developer has heard the opposite. Stop watching tutorials. Get out of tutorial hell. Just build things and struggle until it clicks. The research behind John Sweller's claim says that advice is half right, and the half that's wrong costs beginners a lot of evenings.
The algebra students who solved less and learned more
In 1985, Sweller and Graham Cooper at the University of New South Wales ran five experiments on how students learn algebra.
The first compared Year 9 students, Year 11 students and university maths students. The experienced ones were better at recalling equations. They could also tell apart two equations that looked alike but needed different solution methods. They had built mental templates, what psychologists call schemas, for types of problems.
So how do you build those faster? In the next four experiments, some students solved practice problems the usual way. Others studied worked examples: the same kind of problem, already solved, step by step.
The worked examples took far less time to get through. And on the test afterwards, the example group solved similar problems faster and made fewer mathematical errors.
There was a catch, and it matters later. The advantage only held for test problems with the same structure as the examples. Change the shape of the problem and it faded.
Why the struggle doesn't stick
Three years later, Sweller tried to explain why in Cognitive Science. It is usually treated as the starting point of cognitive load theory.
When you face a problem you don't know how to solve, you fall back on what he called means-ends analysis. Look at where you are. Look at the goal. Find a move that shrinks the gap. Repeat. It works, mostly. But to do it, you have to hold the current state, the goal, the difference between them, the moves available and a stack of subgoals in mind at the same time.
Sweller's point was that this "may be of such a magnitude as to leave little for schema acquisition, even if the problem is solved." You can reach the answer and learn almost nothing about why it worked.
He backed it up. In trigonometry studies he reported with Owen, students chasing one specific unknown made four to six times as many mathematical errors as students told to find every side they could. Removing the specific goal removed the frantic search. His conclusion was blunt: the emphasis on problem solving in maths teaching was "based more on tradition than on research findings."
The working-memory angle is simple. As Sweller and his colleagues later put it, only a few elements, or chunks, of new information can be processed at once. A beginner debugging an unfamiliar error with six tabs open is spending all of them on the search.
You've probably lived this. You got the thing working at 1 a.m. and couldn't have explained the fix the next morning.
Does this hold for code?
There's decent evidence it does, at least early on.
Jarmo Tuovinen and Sweller compared exploration with worked examples for learning a database program. Students with no database experience gained more from the examples. Students already familiar with databases did about the same either way.
My favourite programming study is a small one. In 2012, Lauren Margulieux, Mark Guzdial and Richard Catrambone at Georgia Tech taught undergraduates to build Android apps in App Inventor from video and text instructions. Both groups got the same complete worked example. One group's steps also had short labels grouping them, like "Handle Events from My Blocks" and "Set Output from My Blocks".
That was the whole intervention. One reviewer called it "close to trivial: writing headings every few lines." According to Guzdial's write-up of the 40-student experiment, the labelled group attempted and completed more parts of the assessment tasks, and did it faster. A week later they did better on a task that asked them to apply what they'd learned to something new.
The biggest summary so far is from maths. A 2023 meta-analysis by Christina Barbieri and colleagues pooled 43 articles, 55 studies and 181 effect sizes and found a medium effect of worked examples on performance (g = 0.48). Correct examples on their own worked best. One result surprised me: pairing examples with self-explanation prompts made the effect smaller in their data.
Until it doesn't
Here's where "just read good code" falls apart.
In 2003, Slava Kalyuga, Paul Ayres, Paul Chandler and Sweller named the expertise reversal effect. Techniques that help beginners "can lose their effectiveness and even have negative consequences" for more experienced learners.
The clearest case came from mechanical trade apprentices. Inexperienced trainees learned more from worked examples, with lower ratings of mental load. As they gained experience, that advantage disappeared. With enough experience, solving problems beat studying examples. The examples had become redundant, and processing them got in the way.
So the tutorial-hell crowd isn't wrong. They're describing what happens after the first few weeks.
The ramp between the two
If examples help at the start and problems help later, the question is how to cross over. Alexander Renkl, Robert Atkinson, Uwe Maier and Richard Staley tested an answer called fading.
Start with a complete example. Then give one with a single step missing. Then two. Keep going until only the problem is left.
In a field experiment in two German ninth-grade physics classes (20 students in one, 15 in the other) and two lab experiments with US college students, fading beat the usual example-then-problem pairs on near transfer. Students made fewer errors while learning, which helped explain the gain. Removing the last steps first worked better than removing the first steps first. The results for far transfer were less clear.
Try this today
Pick something you're new to. Your first recursive function, a SQL join, a custom React hook.
Find two or three clean, solved examples and read them slowly. Write your own subgoal comment above each chunk: // base case, // shrink the input, // combine results.
Then take a fresh example and delete its last step. Write that step yourself. Next time, delete the last two. Keep going until you're starting from an empty file.
And watch for the flip. Once a blank file feels easy, stop reading tutorials on that topic. They've started costing you more than they give.
Where Recl fits
I built Recl partly for that crossover. When I save a good talk or a well-written walkthrough, it pulls out the key takeaways, which is close to the labelled-subgoal version of the thing. Later it brings the save back as a recall question, so the worked example slowly turns into something I have to produce from memory. You can browse some public summaries on library.recl.app.
Read the solved version first. Then take the steps away, one at a time, until you don't need it.
I'm Asutosh. I write about how the brain learns and remembers, and I build Recl, a tool for remembering what you watch and read.
Sources
- Sweller, J., & Cooper, G. A. (1985). The use of worked examples as a substitute for problem solving in learning algebra. Cognition and Instruction, 2(1), 59–89. https://doi.org/10.1207/s1532690xci0201_3
- Sweller, J. (1988). Cognitive load during problem solving: Effects on learning. Cognitive Science, 12(2), 257–285. https://doi.org/10.1207/s15516709cog1202_4
- Tuovinen, J. E., & Sweller, J. (1999). A comparison of cognitive load associated with discovery learning and worked examples. Journal of Educational Psychology, 91(2), 334–341. https://doi.org/10.1037/0022-0663.91.2.334
- Margulieux, L. E., Guzdial, M., & Catrambone, R. (2012). Subgoal-labeled instructional material improves performance and transfer in learning to develop mobile applications. Proceedings of ICER 2012, 71–78. https://doi.org/10.1145/2361276.2361291 (experiment details from Guzdial's write-up: https://computinged.wordpress.com/2012/06/05/instructional-design-principles-improve-learning-about-computing-making-measurable-progress/)
- Barbieri, C. A., Miller-Cotto, D., Clerjuste, S. N., & Chawla, K. (2023). A meta-analysis of the worked examples effect on mathematics performance. Educational Psychology Review, 35, 11. https://doi.org/10.1007/s10648-023-09745-1
- Kalyuga, S., Ayres, P., Chandler, P., & Sweller, J. (2003). The expertise reversal effect. Educational Psychologist, 38(1), 23–31. https://doi.org/10.1207/s15326985ep3801_4
- Kalyuga, S., Chandler, P., Tuovinen, J., & Sweller, J. (2001). When problem solving is superior to studying worked examples. Journal of Educational Psychology, 93(3), 579–588. https://doi.org/10.1037/0022-0663.93.3.579
- Renkl, A., Atkinson, R. K., Maier, U. H., & Staley, R. (2002). From example study to problem solving: Smooth transitions help learning. The Journal of Experimental Education, 70(4), 293–315. https://doi.org/10.1080/00220970209599510



Top comments (0)