9 Tricks to Code More Productively
How I get things done, and you can too
Coding can be a lot of fun, but what makes it even more fun is achieving goals well and quickly. That’s why I wrote this piece, which brings together all my productivity tricks that you can hopefully benefit from too.
Have fun and don’t get distracted!
1. Don’t Let Yourself Be Distracted
What a cool transition, huh? OK, let’s get to the point: You can lose a lot of time by putting off important things instead of achieving goals (which we’ll get to in a minute).
It is actually so absurd. Actually, we do nothing else but expose ourselves to short-term pacifications in order to keep us from the actual, maybe very exhausting, work. But in the end, this will not help at all. It only makes us have more negative stress.
Create the right mindset against procrastination and distraction
Be aware that it won’t do any good and only causes more problems. The distraction itself is usually a complete waste of time — I personally tend to open YouTube or Instagram while I’m working to see what’s new. So I invest a lot of time every day to expose myself to potential distractions several times.
The point is that it doesn’t make any difference if I update my subscription box on YouTube every hour or just once a day. In the end, I’ll find the same content in both cases.
And what’s really sad is that, most of the time, I’ll only be consuming things that I’ll have forgotten by the evening — without any added value.
To improve your sense of time, you should start paying attention to the time regularly. Then you will be able to judge how long something took you and you will soon become less wasteful with it once you have had your first moments of shock.
Eliminate these distractions as well
Put your phone away. Close your unnecessary browser tabs. And there are so many other things you should eliminate. You have to determine exactly what they are.
Don’t worry, you’re not missing anything.
2. Set Goals for Yourself
Various studies prove that it makes sense to set goals for yourself, but you don’t need actually studies to prove that. It’s quite logical. How often do we have only rough goals in mind, then lie to ourselves while trying to reach them and finally lose sight of them?
A good example of such a bad goal is the annual New Year’s resolutions. “Do more sports.” You haven’t done any sports before? And now you do ten push-ups a week? Then congratulations — you have reached your goal.
And the funny thing is that you and I know something like that about ourselves. Am I not right?
But we are by no means the only people who feel this way because there are clear rules on how to set goals so that you don’t lose sight of them as you might with your resolutions.
One system for optimal goal setting is the SMART principle, which can be used for just about anything. And I wouldn’t add this to the list unless you were to use it for your programming work as well.
SMART stands for Specific, Measurable, Attractive, Realistic, Time-Bound.
- The goal should therefore be defined as precisely as possible (specific).
- Progress should be measurable.
- The goal should appear attractive to ourselves.
- The goal must be realistic. Otherwise, we will be disappointed soon.
- It should be time-bound so that we have to reach it by a fixed date.
So this could be your annual resolution: Go to the gym twice a week, build muscles to look better, all year long. It’s already realistic and measurable.
3. If It’s Not Tested, It Doesn’t Work
You have to test everything afterward anyway — and the nice thing is that this approach is wonderfully compatible with the SMART principle.
You could set yourself the goal of developing several small features or components today, and each time, you test them in isolation.
The worst thing is when you’re standing in front of an actual finished project, but then something doesn’t work and you don’t know why. It could be even worse in production. Believe me, the wildest things happen when the finished project hasn’t been tested in every imaginable scenario.
4. Document and Refactor Everything Well
Better take those few extra minutes and write a comment, take notes, secure your intermediate status (e.g. with Git), and think about some meaningful variable names.
Nothing is funnier/sadder than finding incomprehensible, older source code from someone else… and that someone is actually you from a year ago.
And what about refactoring now?
At first glance, it doesn’t change the result of the code, but you should take enough time to do that as well because you have to document much less if the code is kept simple and easy to understand.
Especially if you give up your pride and ask someone else for help, it can help that person tremendously to help you because your code is simple, understandable, and well documented.
5. The Right Environment Is Crucial
After the first point, you must have gotten up straight away and gone to a place with fewer distractions, right? No? Then think about it again. Or at least open the window for a minute. By airing your room regularly, you can prevent breathing in too much carbon dioxide, which can lead to tiredness and headaches.
If you also have the time, then why don’t you go out for a walk? It’s incredibly healthy, stimulates concentration, and also gets you thinking new thoughts. And before I forget: You get fresh air too.
And I was serious about changing rooms. Some studies show that a change of room every now and then can increase your concentration.
But with your environment, you can also directly understand your own IDE. Knowing it inside and out is often very helpful. That’s why I think it’s worthwhile to invest a few minutes and get to know its features.
For example, for a long time, I didn’t know that you can edit several lines of code at once in Visual Studio Code. That could have saved me a lot of work.
How you spend time in your environment is also crucial
If you’re in a hurry with a project, maybe you shouldn’t be in a room that screams for unmade housework. Postponing important things gets us into the wildest state, even if it’s housework that we usually like to do without.
Have you ever thought about a high table? Maybe you should because not only are many experts now saying that sitting is the new smoking habit, but some studies (and my experience) show that standing makes working more productive.
6. Avoid Making the Same Mistakes Every Time
When I personally started learning Node.js, I constantly stumbled upon problems with cross-origin resource sharing that were actually easy to avoid. Of course, I couldn’t know this at first, but from the second and third time such problems occurred, I should have known.
Of course, at some point, you know how to fix such things purely from experience. But for the wide gap between being a noobie and an expert, it makes sense to write down all possible problems and errors and how to solve them. For this purpose, I have put up a whiteboard in my room.
7. Learn to Type Faster
There are absolutely no excuses for not learning to type fast. I’m learning it myself, and even though it can be exhausting and of course takes time, it’s a good investment in the long run.
Furthermore, you can avoid outbursts of anger and the destruction of peripherals with fewer typos.
8. Automate As Much as Possible
We have already talked about refactoring and documentation. But the good news is that you can easily automate smaller tasks that are very valuable.
For example, you can use various tools to automatically refactor and test your code. You can also automate your work as a programmer in any other area you can think of. Reusable components can be easily reused with platforms like Bit. UI testing & code analysis can be automated even today.
Your time is simply too valuable to spend on meaningless tasks.
9. Dare to Ask for Help
Have you been trying to fix a bug you know absolutely nothing about for hours? Or maybe you managed to fix it through prolonged, clumsy attempts.
Congratulations, but in my opinion, you should have asked for help sooner.
Whether you’ve come across existing answers on Stack Overflow or elsewhere doesn’t matter.
Programmers are blessed with a very helpful community on the internet, so feel free to ask someone. You can often also create value for others because you are not the only one in the world with this bug, but you might be the first and only one who dares to ask. Everyone after you will be very grateful that you have reported your problem.
And even if you have managed to solve the bug by yourself without truly understanding why, many problems always appear in a pattern. As such, it’s far better to grasp the whole matter behind it so that you can handle it by yourself next time.