How to Improve Your Coding Efficiency Immediately

How to Improve Your Coding Efficiency Immediately

written by Timothy LeBon

·

6 min read

We have all been in situations where we tried to get some code down, but couldn’t focus anymore. Instead of solving the challenges ahead of us, we switched to texting or mindlessly scrolled through different files. It doesn’t need to be like this. There are some simples tips that will immediately improve your coding efficiency.

We’ve all been there: it's after 12 am. You are staring aimlessly into your code shuffling back and forth through different files. What were you even trying to fix? Everything is a mess. Where is the file I’m looking for again? Nevermind, I’ll just send some texts then. It really doesn’t have to be like this. I am optimistic that I can offer you some tips to avoid this situation in the future. Because while we can end up being a person who gets distracted often, we don’t have to. I have some sure-fire strategies to keep you on task and productive when it's time to code. These suggestions aren’t just from me either! I asked around and got some tips from people who have been in the game far longer than me. So let’s dive into it!

Standard Productivity Warning

If you happened to read my last article, you know that I’m serious about productivity 😅. Well, I want to be clear off the bat: those standard rules still apply. Put your damn phone away, appear offline, set your pomodoro-timer. Now let’s focus on how we can improve our productivity in the context of coding. Probably this will be the biggest takeaway for productivity: Set some uninterrupted time for coding. cmd-W other windows and get to work. Note: unless stated otherwise, all of the shortcuts I recommend will be for VSCode/Mac. (apologies to everyone else, but the techniques are still valid in other contexts!)

The Basics of Coding Efficiency

So it's Monday, the sprint just started, let's start focusing on our story. You probably need to investigate it to understand the actual tasks and the order of them. So do that and start making some notes. Go through your story, write a checklist of things to do when starting a larger task. I use Notes on Mac or physical post-its to keep track of this. Be systematic! Do tasks and then cross them off. The advantage of doing this on your computer is you can keep track of your tasks and then pass them off to another colleague if needed. Track what needs to be done, and the other to do’s, as well as daily tasks and any open questions you might have. Leave TODOs throughout your code for things to finish whenever you are getting side-tracked

Development: Actual coding-related efficiency

Write simple and understandable code with proper documentation when it’s necessary for other developers to understand. As the maxim goes: “Any fool can write code that a computer can understand. Good programmers write code that humans can understand.” — Martin Fowler I think we can go further than that though. JSDocs is a great way for you to not only document code, but to define expected types and even the action of functions. It integrates seamlessly with VSCode, and as you see below your function will have the content you provide, making it super easy for anyone (or yourself) coming to the code later.

hn1.PNG

It is also prudent to have some understanding of different design patterns and to know when they can be beneficial to your code. Also, learn anti-patterns and know how to avoid them. In fact, learn your language as much as possible: learn when it is a good time to use different stylistic approaches- for speed, for understanding, or for reusability. Stop using your mouse and trackpad wherever possible! Doing everything with keyboard shortcuts will speed up development time a lot. Hemin from diconium recommends ‘Key Promoter X’ for PHP storm that notifies him every-time he forgets to use a shortcut key. This helps him over time to rely more on the shortcuts and less on the slower options.

Workspace Optimization: IDE/ ease of use

Take advantage of and learn all of the benefits your IDE offers you. In this day and age, they will probably do more coding than you do if we add it all up. That means: get your linter set up, set up formatting the way that you like (4-space tabs FTW) and make sure your team has an aligned setup for these things as well. Take advantage of autocomplete options, and if you are a FE developer learn some emmet abbreviations, they can save lots of time.

hn2.PNG

Christian Heillmann (@codepo8), Principal Program Manager for Browser Tools at Microsoft, also suggests to stay in one context.

I think the biggest tip I can give is to learn your development environment. It is tempting to be all cool and minimalistic in your editor choice, but the fact is that development is complex and it is easy to make mistakes… Even better are those [IDEs] that allow you to stay inside one context. It may not seem like much to jump from editor to terminal to browser, but over the hours every switch in context is a high cognitive cost that tires you.

I must say I agree with this as well, I am a big fan of doing an integrated terminal (ctrl +~) (or two [cmd + ]) along with two tabs of code. And when the need calls for it I will also join my browser with my IDE window in one screen using Split View on Mac. Googling ‘Tiling Window Manager” will help you find similar functionality for other OS’s. Another idea from the office: Quokka is a great tool for quickly prototyping and testing inside of your IDE. You can see the output and any missing dependencies inline, even before saving.

Shortcut Ideas: Some of my favorites

Perform ctrl+W to close windows with distracting programs like instant messaging or emailing.

cmd + D in VS Code is a lifesaver. Selecting the same text in different lines allows you to optimize a lot of things. combine it with other highlighting shortcuts to change whole lines of code and you are a modern-day wizard.

Similar is cmd + option + up/down - which will give you a cursor at the same spot in the line either above or below.

shift+option + F in VSCode is another one I use a thousand times a day. If you have your formatter correctly configured its a great way to get everything aligned.

This article has a lot of other great tips for VScode, give it a read.

I also recommend setting aliases for commands you use frequently: git is a good place to start. here are a few simple ones I use to get you started.

last = log -1 HEAD acm = !git add . && git commit -m s = status n = !git checkout -b co = !git checkout

To set these, go ahead and open .gitconfig and paste these in aliases. There are many ideas for aliases online, I encourage you to look for some more!

In Closing

That's really all of the suggestions I have for this topic right now. Don’t get me wrong: this is just scratching the surface. I do hope it has given you some new ideas though! There are so many ways to improve your efficiency when you are coding. At the end of the day, it really comes down to what works best for you. Just make sure you are doing it in a quiet place, without interruption.

And please: leave us some extra tips in the comments if you have any!

Originally published on: medium.com/rewrite-tech/improve-your-coding..