Welcome to Code Chatter, your go-to series for conversational coding insights. What makes this series of questions different from all the others? W...
For further actions, you may consider blocking this person and/or reporting abuse
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
I take a break, write down why I'm stuck, and talk with a human about it.