There is nothing that takes the wind out of my sails like hitting a roadblock in a software project. This is the stuff that leaves me feeling rejected and dumb. I have found that hitting roadblocks is not always something that happens to you, it is something that can be minimized... to a degree.
There are two forms of roadblock I have noticed. The mental roadblock: This is when I get stuck on a design, or I feel there is something not quite right about the process I have designed but cannot put a finger on it (I will talk about another time). Then there is the physical roadblock: bugs that prevent you from continuing on your project or the lack of technical knowledge to solve a particular problem correctly, this is the kind I am talking about today.
It is easy to give up and say "Programming is not for me", abandon the project or just stew on it indefinitely blocking your ability to work on anything else...That SUCKS!!! I hit roadblocks all the time, there is always that line of code or that library that is not working like it is supposed to. I hit roadblocks so often I start getting worried when things go too smoothly. I have even caught myself putting bugs in my own code when things are going too well to make sure I am actually making changes to the correct code base. Over the past couple of months I have been stewing on this problem and so there are a couple things I do now to try and reduce roadblocks and they seem to work for me so far.
Plan out your project! I cannot stress this enough. I usually hate doing this because if it is a job or side project I am really excited to do, the last thing I want to do is sit down and actually plan it, go step by step and plan out each section of the app. I have the tendency to just jump into the code and start hacking away. Regardless of how I feel, by not planning I have agreed to work on a software project for a longer time than necessary. Planning gives foresight into the project and can help make decisions on what is important while looking at the project on a macro level. It has also helped me find problematic areas early and so I can address them by research or talking to the client.
Celebrate the little things
I set goals like, after I make the header red and responsive, I am going to eat a kit kat to celebrate. My version of Treat yo self. Once I learned to celebrate the little things, it allowed me to sufficiently break down the project into mini goals and my celebrated successes gives me a second to put the project back into perspective and then get on to the next task. I have also planned out each task so I have a mental note of how this problem should be solved before I embark on them and so I always see the light at the end of the tunnel, which keeps me positive and motivated.
Avoid new things
Similar to my deploy first rule, I have a bunch of rules that guide my software process. Some come from experience and some come from listening to wiser engineers. One I recently picked up is that when you are working on a project, only pick up a new framework, library or language if you are experienced in the problem domain of what you are trying to solve. Do not "check" out ruby when you are making software for that power plant. It is like making Spaghetti Bolognese, which you have never made before for your sister's wedding, this wont be the time to "check" out your girlfriends new experimental Tomato and garlic mix. Staying away from new tools when dealing with mission critical jobs or side projects you want to build fast, is one of the better ways to save yourself hours. Feel free to check out new shiny things when you are making boring old stuff.
There are other basic things that are no brainers to most programmers, like google and stackoverflow are your friends. Always ask a co-worker or friend for advice or do rubber duck debugging. I do not think I will ever stop hitting roadblocks in my career and I am ok with that, I think it is a symptom of growth. Minimizing roadblocks is an area of continual improvement but knowing there are tons of solutions to being stuck makes it less annoying and daunting for me.