The Rubber Duck Method for Debugging [Technique Tuesdays]
Also very useful when it comes to algorithm design and your interviews
To learn more about the newsletter, check our detailed About Page + FAQs
To help me understand you better, please fill out this anonymous, 2-min survey. If you liked this post, make sure you hit the heart icon in this email.
Recommend this publication to Substack over here
You’ve been stuck at a problem for a while,
No matter what you do, you can’t debug the code.
There are more print statements in your code than there are gold chains in a rap video.
So what do you do? Call it quits, listen to the Computer Science nerds, and use a debugger?
Of course not. I would never suggest such heresy to you.
Enter the almighty rubber duck. Possibly one of the most powerful tools in a developer’s arsenal. It will you a lot in writing code throughout your career. Done right, it can be an amazing tool for your interviews as well. No, I’m not making this up. You’ll see.
Key Highlights
What is the Rubber Duck Method- The rubber duck method is a method for debugging your code. It helps both with logical and runtime errors (most good IDEs will help you fix syntax errors easily). It relies on a simple premise- as you walk through your thoughts and code, you will automatically spot a lot of the errors that are causing the bug.
How it works- Buy a rubber duck. Anytime you have an error that you start having, start explaining the error to Rubber Duck. Explain what the error is, what line is causing it, what happened prior to that point etc. Don’t forget to explain why you took certain steps/implemented certain procedures. 99 times out of 100, you will find the fix. Remember to speak to the duck OUT LOUD. It’s a rubber duck. It can’t communicate with you telepathically.
Why it works- When we speak we force ourselves to articulate why we did things one way over another. Our minds will naturally start forming connections and lead to insights. Speaking out loud is especially useful because when you’re just thinking to yourself- your mind will make a lot of leaps. Speaking out loud will stop your brain from making those leaps. This is also why the recommendation for proofreading any manuscript is to read it out loud. You’d be shocked at how many more errors you catch compared to just reading it silently.
In your interviews- In your Leetcode style interviews, you will probably not get to run your code and debug it. But a variant of this technique will help you a lot. Treat your interviewer as the rubber duck. Start speaking out your thoughts and processes out as soon you hear the problem. If you’re stuck in a place, take a step back and describe where you are stuck .If things worked in an ideal situation, what would that look like? What do you need to do to convert your current situation to that ideal? You’ll be surprised how quickly you will find your answers. And your interviewer will be impressed by your communication skill.
This technique (especially in the interview context) requires a strong foundation based on knowledge of ideas and experience implementing these ideas. This is what will allow your brain to become much better at making connections as you talk through this. The best way is to show up regularly and follow the plans. For extra boosted results- make sure you read this post on mastering skills and this one on Microsoft’s research into what makes great software engineers.
To those of you that want to learn more about this technique, I’m linking a video below. One glance through the comments will show you how effective this technique is.
I created Technology Interviews Made Simple using new techniques discovered through tutoring multiple people into top tech firms. The newsletter is designed to help you succeed, saving you from hours wasted on the Leetcode grind. I have a 100% satisfaction policy, so you can try it out at no risk to you. You can read the FAQs and find out more here. Use the button below to get 20% off for upto a whole year.
Before proceeding, if you have enjoyed this post so far, please make sure you like it (the little heart button in the email/post). I also have a special request for you.
***Special Request***
This newsletter has received a lot of love. If you haven’t already, I would really appreciate it if you could take 5 seconds to let Substack know that they should feature this publication on their pages. This will allow more people to see the newsletter.
There is a simple form in Substack that you can fill up for it. Here it is. Thank you.
https://docs.google.com/forms/d/e/1FAIpQLScs-yyToUvWUXIUuIfxz17dmZfzpNp5g7Gw7JUgzbFEhSxsvw/viewform
To get your Substack URL, follow the following steps-
Open - https://substack.com/
If you haven’t already, log in with your email.
In the top right corner, you will see your icon. Click on it. You will see the drop-down. Click on your name/profile. That will show you the link.
You will be redirected to your URL. Please put that in to the survey. Appreciate your help.
In the comments below, share what topic you want to focus on. I’d be interested in learning and will cover them. To learn more about the newsletter, check our detailed About Page + FAQs
If you liked this post, make sure you fill out this survey. It’s anonymous and will take 2 minutes of your time. It will help me understand you better, allowing for better content.
https://forms.gle/XfTXSjnC8W2wR9qT9
I see you living the dream.
Go kill all and Stay Woke,
Devansh <3
To make sure you get the most out of Technique Tuesdays, make sure you’re checking in the rest of the days as well. Leverage all the techniques I have discovered through my successful tutoring to easily succeed in your interviews and save your time and energy by joining the premium subscribers down below. Get a discount (for a whole year) using the button below
Reach out to me on:
Instagram: https://www.instagram.com/iseethings404/
Message me on Twitter: https://twitter.com/Machine01776819
My LinkedIn: https://www.linkedin.com/in/devansh-devansh-516004168/
My content:
Read my articles: https://rb.gy/zn1aiu
My YouTube: https://rb.gy/88iwdd
Get a free stock on Robinhood. No risk to you, so not using the link is losing free money: https://join.robinhood.com/fnud75