Activity: Rubber Duck Debugging

(no submission)

Purpose: Experience a debugging method (this will help you distinguish between "testing" and "debugging")
Reminder:

Important note, please read
We may take pictures while you are doing this activity. The pictures will show an overall class activity (that may or may not show your face clearly); no individual picture will be taken unless you notify me your preference. I would like to post pictures of our activity on the class website. I am asking for your consent to (i) take pictures while you are doing this activity and (ii) post pictures on the course website. If you do not agree to give your consent, please email me. I will exclude any pictures that show your face.


Rubber duck debugging   is a debugging technique commonly used in software engineering. The core idea is that a programmer explains to the duck what his/her code should do (line-by-line) and what it actually does. The programmer explains a problem to the duck. As the programmer explains, the programmer refines his/her thoughts which often leads to possible solutions.


You will have 10 minutes to complete this activity.

  1. Everyone will talk through this activity. Let's create a lively class meeting!!
  2. Say "Hello" to your buddy, "The Duck" feel free to give "The Duck" a name. "The Duck" will be your debugging buddy today.

    Alternatively, you may talk to or or or any friend of your choice.

  3. (you have 2-3 minutes) Read and analyze  patternIndex.java. There is a problem in the patternIndex method.
    • When Upsorn runs the program with 2 sets of inputs (the first set: enter-your-string and you; the second set: enter-your-string and string), the program seems to work fine with the first set but fails the second set. Help Upsorn find the cause of problem in this program.
    • You may read and analyze the code with or without running it.
    • You may not use any forms of "print" or "System.out" statements. You may not use other debugging tool or software.
  4. (you have 5-7 minutes) Talk to your buddy (Yes, talk to your buddy — this is the main process of the "rubber duck debugging" method)
    • Tell your buddy what the patternIndex is supposed to. What is its functionality? Based on the source code, explain to your buddy line by line.
    • Tell your buddy what the patternIndex should produce (or return) when the incoming inputs are
      subject = "enter-your-string"
      pattern = "you"
    • Tell your buddy whether the patternIndex produces the output it is supposed to produce. If it does not, you will tell your buddy why it does not. You will share with your buddy what / how you will fix the method.
    • Tell your buddy what the patternIndex should produce (or return) when the incoming inputs are
      subject = "enter-your-string"
      pattern = "string" 
    • Tell your buddy whether the patternIndex produces the output it is supposed to produce. If it does not, you will tell your buddy why it does not. You will share with your buddy what / how you will fix the method.
  5. Be prepared to share your experience and solution to the class



[Images: bunny and skeleton by Ekarin Apirakthanakorn]


Copyright © 2025 Upsorn Praphamontripong
Released under the Creative Commons License CC-BY-NC-SA 4.0 license.
Last updated 2025-08-28 18:46