Why is 'rubber duck debugging,' which involves talking to a duck doll to solve a problem, effective?



When debugging a program, instead of quietly struggling in front of the screen, there is a technique called '

rubber duck debugging ' in which you explain the code line by line to a rubber duck doll placed on your desk. Elliot Valoi, a computer scientist at the University of Sydney, explains why rubber duck debugging is effective.

Stuck on a problem? Talking to a rubber duck might unlock the solution
https://theconversation.com/stuck-on-a-problem-talking-to-a-rubber-duck-might-unlock-the-solution-261675

For example, imagine you're assembling a piece of furniture you bought yourself, but get stuck halfway through. You're starting to get frustrated as the piece of furniture never seems to be finished, when your partner comes into the room. You say to your partner, 'I'm doing everything exactly as it says. Look,' but halfway through explaining the process, you realize you've skipped a step: 'First, use screw number 1 to connect A to B, then use bolt number 3 to connect B to C, and then connect B and C to D...huh?'

We've all had the experience of being stuck on something and trying to explain the problem out loud, only to have it all make sense. In programming, this is called 'rubber duck debugging.'



The term 'rubber duck debugging' is said to have first appeared in the university textbook ' The Pragmatic Programmer: From Journeyman to Master ,' published in 1999. This textbook is about programming and software engineering, but rather than presenting a systematic theory, it outlines a practical development process and explains development methodologies using analogies and folk tales such as the ' boiling frog law ' and ' stone soup .' Rubber duck debugging was also introduced in this book.

The gist of rubber duck debugging is that when you can't figure out why your code isn't working, you put a rubber duck on your desk and explain out loud what the code does, and as you talk to the duck you realize there's a discrepancy between what you think it's doing and what it actually does.


by Tom Morris

'When many of us first read, we think aloud, reading along as we go,' Valoy says. 'Reciting things aloud has the enlightening power of helping our brains 'hear' issues they couldn't previously acknowledge.'


Explaining something to others forces you to 'break down the content into conceptual parts, integrate them with existing knowledge, and organize them logically.' A study published in the United States in 2013 found that studying with the intention of teaching it to others and then actually teaching it to others 'leads to a deeper and more sustained understanding of the content.' The study also showed that explaining something to yourself is also an effective strategy.

If that's the case, why use a duck doll instead of just talking to someone? Valoy says, 'There are certain limitations to talking to a human.'

Humans are context-dependent and act based on past thinking and experiences. This means that we may make assumptions about previous attempts to solve a problem and miss mistakes. Also, our preconceived notions can make it difficult to identify where we went wrong.

But that's not the case with the duck doll, says Valoi: it just stares back at you with its cute, expressionless face while it explains things in minute detail and with precision.



Of course, ducks are just one example; other things like beautiful girl figurines or cacti would also work. If you're hesitant to talk to silent objects, some researchers advocate using large-scale language models like ChatGPT instead of ducks. While ChatGPT isn't human, it can identify errors and suggest fixes by explaining code line by line. It's been shown that people are more likely to talk to objects if they respond. In fact, a paper published in 2024 by researchers at Tokyo University of Agriculture and Technology found that when a duck doll was equipped with interactive features—such as nodding or short, neutral responses when a button was pressed—people tended to feel less hesitant to talk to it.

'The next time you're stuck at work, can't write a sentence, or trying to understand a complicated email, turn to the little yellow duck and see if explaining your problem out loud can help you arrive at the answer,' Valoy said.

in Software, Posted by log1i_yk