How to Improve Your Coding Efficiency Immediately
By: Timothy Lebon
Tags: Software Development, Efficiency, Programming Languages, Coding, Vscode

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.

A simple JSDoc example for a function, note the types inferred in the pop up as well.

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.

An emmet abbreviation and its output (example from Emmet Docs)

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!