Have you ever sat staring at your screen, trying to figure out where your code is wrong, but nothing is popping out at you? You are looking at the code, line by line, again and again. Nothing looks wrong, but the error message when you run your code just won’t go away. You try this and you try that, but to no avail. Two hours later you figure out it was just a simple typo, and your code finally works. The problem is, you just wasted a big part of your day, and grew incredibly frustrated. If you are a new programmer, this may lead you to doubt your ability to succeed on this career path.
If you have written code for any length of time, you have probably come across a bug or a piece of code that has given you fits. Sometimes it can be a typo, or some kind of syntax error that you stare at the screen and just don’t see. Other times you’re integrating with an API and it’s just not giving the result you expect. I have personally battled with code like this for hours at a time. It was more common place early on in my career, but it still plagues me every now and again. In the beginning of my career it was usually attributed to a lack of understanding, now it’s usually caused by the stress of trying to juggle priorities or meet a deadline.
With that said, since there are constantly new platforms and frameworks available to dabble with, and lack of understanding still kicks in from time to time. For example, I love Ember (http://www.emberjs.com), but when I first started messing with it, I wanted to throw my computer out the window. Most developers when seeing a new technology that excites them, don’t want to take the time to read the documentation(that’s another chapter). They like to jump right in. I am one of those developers. Before throwing myself into learning a new framework, which includes reading the documentation, I want to see how it can make the stuff I build better, make my job more fun and help me to become more efficient. So jumping right into a new language or framework before having a good grasp on how things work is common place, but it also can be very frustrating.
The good news is there is a solution that works almost 100% of the time. While everything tells us to keep pounding the keyboard because we are just a small change away from getting everything to work, we end up making 100 small changes before it finally does. By the end of the day we want to pull our hair out and we have spent hours getting something small to work. This isn’t fun, our productivity for the day was tanked, and depending on whether or not you got it fixed you didn’t build anything of value for the end user. So what is the solution?
Take a break
We developers can be really bad at wallowing at our desk for 8 straight hours getting lost in the code. Even when we aren’t stuck on anything, following this practice throughout the day will make you more productive. Here is what the break looks like:
- Literally get up from your desk and walk away (or just walk away if you have a standup desk; that’s another proverb for a later date)
- Go relax for 5-15 minutes and completely disconnect from what you were just working on. Go take a walk, grab a coffee, drink some water, do some pushups, you get the picture. If it’s close enough to lunch, go to lunch. This gets your mind clear of the frustration you were feeling and allows you to come back to your desk and approach the problem with the fullness of your skills.
- Come back to your computer, and review the documentation for whatever you are working on. Stop and read it for understanding. Don’t read a small piece, think you have it and try something new. Get the whole picture, then go back to your code.
Whenever I follow these steps, I usually figure out the issue I have been dealing with right away. Whenever I don’t, I usually waste a large chunk of time that could have been spent building more stuff.
Happy coding!