Create templates to quickly answer FAQs or store snippets for re-use.
1 - Google.
2 - Ask to my teammates.
3 - If it's a big task I try to split it in a small ones or try with different approaches.
4 - Just practice some relaxing and easy going task like the gym, a shower, a walk or a movie because a relaxed mind works in background and may be you'll find the solution in that moment or the next time that you start to think in the problem you'll be fresh!
Excellent. I especially like the reminder to split the problem down, I definitely need to do this!
Rubber ducky debugging!
Thanks for sharing Desi. I like the idea of using psuedo code. I'll give this a go.
Going for a walk is my personal favourite. Or if I can't do that, make a cup of tea. Something that gives me a chance to stop actively thinking about the problem.
I highly recommend the book Pragmatic Thinking and Learning for more details, but essentially there are two "modes" of thought you need to engage. One is the linear mode, essentially your inner monologue, which is useful for working through problems logically. The other, referred to in the book as R-mode, is more unconscious, and works like an asynchronous search engine in that it will work away in the background unnoticed and then suddenly return ideas.
Actively using the linear mode stops R-mode from working, but if you go do something else and switch off your l-mode, it has a chance to run.
Very often I've been stuck on a problem, then gone home or out to the shops to buy lunch, and very quickly been hit by the answer, or at least a new idea.
Rubber duck debugging is another good one. Explaining the problem to a colleague will often lead me to the answer even without any input from them.
Thanks Matthew, lots to think about there! When I get a chance I like to work in a pair, but it isn't always easy as I'm primarily remote.
Rubber duck debugging can work with pets or inanimate objects (it helps if it's something you can anthropomorphize, such as a stuffed toy), or a non-programmer. It's the act of explaining it that gets your brain working.
I really should give this a go. I spend a lot of time alone in my home office. I could speak with an inanimate object quite easily without being interrupted.
When I get stuck... I usually ask a friend about my code. Even the process of me explaining the code to him/her may get me in the mindset I need to be in to detect a bug.
However... Probably the longest time I've ever been stuck on something was trying to find a way to perform mathematics on generic types in C#... I worked on this topic for months before I found a way to do it. I actually used generic types, runtime compilation, and delegates. :) I was only able to see this solution after exploring topics that were (at the time) outside my comfort zone. So you need to push yourself at all times to learn.
For me i don't have that fixed routine when i get stuck.
But taking my mind off that issue completely(trough whatever: sometimes just sleeping can do the work ) is so helpful, and the solution comes right after getting back, or suddenly pops up during that break.
I think my best ideas to problems I spent a whole day struggling with have always came to me on the commute home. Whether that was the 30 min walk home from university, 5 min walk from my office to my flat or my current 1.30 hour commute from work.
As others here have said and many other people as well, doing something simple and mindless is sooooo helpful to get some ideas to pop up.
On commutes home, I've had to whip out my phone to write down an idea I just came up with, just so I don't forget it when I'm actually at work the next day.
This is what helps me the most. That being said, I agree with most of the other comments here and they also provide good other ways to climb out of a debugging whole!
Usually this happens when I try a new library or there was an update to the one I use. Then I end up spending 7 hours reading how that library works and tracing the APIs that I use in their sources... Not the best approach becuase it leaves me too exhausted to do anything else, but at least I REALLY learn the libraries :D
And also the gym, or at least a walk outside. It's really meditational
I do a whole lot of things when I get stuck, not particularly helpful most of them. Once I got stuck writing a unit test for AngularJs and it took me like 3 days to understand the problem and another 5 to reach the solution.
Without looking at what others have suggested I'd say the obvious first, google it. Also if you can ask teammates or other people on the floor, distance yourself from the problem for a moment like go for a walk.
Also, talk to the rubber duck or in the most desperate situation (like I did) get help from an experienced mentor to solve the problem you're facing.
If talking to others isn’t an option then I work backwards and disbelieve my assumptions about the problem one by one.
Excellent, this sounds useful. I'm going to give this a go. Thank you.
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.