How to Debug Using a Rubber Duck


Rubber duck debugging, or rubber ducking, is a method of debugging code in software engineering. The term can be traced back to “The Pragmatic Programmer”, a book by Andrew Hunt and David Thomas detailing a programmer who carries around a rubber duck and debugs their code by explaining it to the duck, line by line. 


Steps: 

  1. Get a rubber duck (preferably a bath-time duck, but any size is okay)

  2. Start explaining the code to the duck making sure to read each logical step out loud and in detail while pointing to the screen so that the duck knows which line you’re talking about

  3. Continue to go through your code until the solution to the problem is found


The main point of the exercise is to have the developer slowly and carefully explain their code out loud, line by line. Since we think faster than we speak, verbally explaining the code forces the coder to slow down and, under the assumption the duck knows nothing about the code, the coder also has to be precise in their explanation which helps them learn and become more efficient in programming. Pointing to each line of code makes them review the syntax and logic right under their finger, making it easier to see where what the code is doing differs from what they think it’s doing. 



Sources: What is Rubber Duck Debugging? - Kenzie Academy (snhu.edu), Rubber Duck Debugging (rubber-duck-debugging.org)

Comments

Popular posts from this blog

Deadly Foxglove

Dancing Bees

Chocolate Cake