When it comes to coding (or anything related to it) there's a rule I believe in with all my heart. It's the Thirty Minute Rule.
The rule is that if anyone gets stuck on something for more than 30 minutes, they should ask for help. By asking for help after 30 minutes it addresses the following things:
Often we are stuck because of something we don’t know, making it impossible to proceed regardless of skill or intelligence.
Makes it so we don’t get frustrated by being stuck on a problem for too long.
Sometimes simply formulating the question to ask allows us to answer the problem ourselves.
From a business standpoint, reduces costs because instead of hours or days or weeks being stuck, we move on after 30 minutes.
Who do I ask for help?
Whoever you can. Co-workers and collaborators are common. If they don't have the answer, online discussion forums, groups, or general social media are useful. This was the original use case for Stack Overflow.
What if no one can give me an answer?
Then you've got a real challenge. Solving hard problems is part of our job.
Shouldn't people figure stuff out on their own?
Often, that's impossible. Many years ago I once spent several days trying to figure out how to package up something for deployment. When I finally got up the nerve to ask for help, I learned that critical details of our environment weren't in the group wiki, but handwritten in the system administrators' notebook. While that was an admittedly insane scenario, it demonstrates that until I asked, there was no way I was ever going to accomplish my assigned task.
Had I asked for help in thirty minutes, I wouldn't have experienced so much frustration. I wouldn't have wasted several days of work.
I had to figure stuff out on my own, shouldn't other people?
I've heard this argument before and it disappoints me.
We should show compassion for others. Why would we want other people to suffer the same sort of frustration we did?
We shouldn't repeat the mistakes of the past.
What if someone asks me a question and I don't know the answer
Then politely admit you don't know the answer. Gently steer the person to others who can help them, or to online help methods.
What if someone asks me questions and I'm too busy to answer them?
Gently guide the person to others who can help them, or to online help methods. Or suggest a time when you will have time to answer their questions.
Does it have to be thirty minutes?
Adjust the duration to best suit your team. A common variation is to increase it to 60 minutes.