Welcome to Code Chatter, your go-to series for conversational coding insights. What makes this series of questions different from all the others? Well, truth be told, not much, but they're still thought-provoking and fun. Join us as we explore the coding world, one witty question at a time.
When facing a particularly difficult problem, bug, or design issue, what strategies do you use to 'unstick' yourself?
Follow the DEVteam for more discussions and online camaraderie!
Top comments (11)
When trying to solve a difficult problem, I usually take a break. I walk away from the problem for a while. During that time, my mind is more settled and Ideas to solve the problem just easily flow in.
The key to solving difficult problems is communication. Communicating with your team or friends always provides a different point of view and can suggest effective solutions.
I usually try to break it into pieces. If I’m having a problem with code, I’ll usually try to write a test to exercise the problem. Small test programs are much easier to use a step debugger with. I usually go there pretty quick since it’s so effective.
I also, unironically, love rubber duck debugging. 🐤
some of all of these, in no particular order, within a loop (not shown here)
First of all, I try every possible scenario in my head. I use the print() statement to find the source of the error, I comment out some portion of my code to be able to identify the code causing the error. If it is a small code(not often) I use Python Tutor visualizer. I run tests and most times if I don't understand the error message I paste it to chatgpt to interpret it for me and identify what is causing the error. Sometimes I would have to paste my code too.
I also use Google and Stack Overflow to find people who once had similar problems.
After trying for long hours I am still stuck. I take a break. Most times I just sleep and I dream about the problem.
The moment I find a solution in the dream I wake up and implement it.
Sometimes I might not dream about the problem. When I wake up I use a fresh perspective to tackle it.
And if after everything I am still stuck. I ask for help. I reach out to people in the dev community.
I have two favorite strategies: taking a relaxing walk 🚶♂️ and teaming up for pair programming 👫💻.
Has anyone ever tried the "Rubber Duck Debugging" 🦆?
If at least five folks vouch for it, I might just get my own rubber duck companion! 🤣🦆👍
Just take a break. I always forget to because in the heat of the moment, it's common for me to think that grinding out a problem for the next 4 hours will be easier than just taking a break. That's not normally the case though, so just take a break.
Rubber ducking to the point of peeling off all the noise and specifics. Once you reach the essence of your issue, you can start looking for knowledge (or better, experts) on the matter.
Mine was a concurrency issue in between http clients when dealing with cookies in a shared cookie har. Yikes!
An approach that works well for me is a variant of rubber duck debugging: I open stack overflow and start writing my question by following the guidelines (explain the problem in detail, and what I have already tried to solve it). Usually when I do this I realize I didn't try every possible solution, I try a few more things to add it to the list and show that I've done my homework, and I eventually find the solution and delete everything I've written.
Also use a debugger to run through the code. For me the debugger is an essential tool.
in no particular order:
Until I solve the problem