Embrace being stuck
As I mentioned in my post about being in Tutorial Hell - being stuck does suck. It makes you feel powerless, dumb and makes you start questioning yourself if coding is something you should do.
I'll go further and say that being stuck will make you want to pull your hair out, punch your screen and go back to that crappy job you once had when you were younger and were getting little to no money.
But as I mentioned in that previous post, being stuck is a very important thing for your growth and you shouldn't fear it.
Why we get stuck
There are many different reasons why you get stuck while coding. Some of these reasons can be because you:
- didn't understand the problem properly,
- didn't break the problem into the smallest bits possible,
- are just tired and need a break,
- haven't encountered this particular problem yet,
- don't have enough experience yet
One thing that I hear all the time from the Complete Developer Podcast is how Will and BJ sometimes get stuck and they talk with each other about the problem that they are facing. Sometimes one of them has some idea of how to solve the problem because they had faced it in the past.
Embrace the suck
When you do get stuck in a problem, you just need to embrace the suck - to accept that something is extremely unpleasant but unavoidable.
There will be times when you get stuck. That's part of being a developer. Do your research and try to view the problem from a different perspective. Take a break, do something different and then come back to the problem, sometimes your brain just needs that bit of extra time to work out how to fix that particular problem.
There is a reason why a lot of times, you go to sleep and the next day you find the solution for said problem.
You will also grow a lot after being stuck, you probably tried a lot of different things, did a lot of research and talked with a few people that could offer you guidance. This is a great learning experience.
What can help to get you unstuck
I've been stuck on problems all the time.
Sometimes I'm implementing a feature in opsdroid and test it out with the bot running, everything works fine, but when I go and write tests for it I get stuck and have no idea how to write the test for it.
I've noticed that most of the times when this happens, the reason is that I need to refactor the code into smaller chunks.
So don't be afraid to delete code that you have spent hours working on.
Search online if someone had encountered that problem before and try those solutions. There is a reason why stackoverflow is so popular.
Check out what people suggest and try to come up with your own version of that code.
Finally, ask for help if you are still stuck.
Opsdroid was the first open source project that I contributed to, when I started I didn't have enough experience with Python and there was a lot of things I didn't understand.
Also, I couldn't read other people's code so I got stuck all the time because I was working on things that required a better knowledge of the language. Still, I got stuck and worked on it and definitely have learned and grown a lot from the experience.
In conclusion, being stuck does suck, but it's part of your growth so embrace it.