More articles

Can you learn to code faster?

Written by
Published on

Today I'm going to discuss a popular topic that comes up in conversation enough that it warrants a bit more information. And that is how to increase speed, achieve better accuracy and overall just have less errors when it comes to writing code. Is it even possible, some would ask.

From my experience, yes, it's more than possible, but not in the way that many would think. Let's dive in. FYI. #3 is my favorite.

Define faster?

Before anything, you need to come up with a proper definition for the term 'faster'. What does that word mean to you when it comes to coding? Do you want to get things done like now, now. Or do you want to spend less time correcting bugs and reviewing your code? Both important, but both require completely different strategies. For example, when I attended university fast meant "at some point today". And that's mainly because deadlines are usually based on days and not months.

When I worked in the corporate world however, fast meant "sometime this month". And that's mainly due to increase in complexity on projects and to the overall project management workflow that is normally in place at most companies. You are not fully responsible for a task normally, and so you time your work with the work of others. So in this case, fast depends on the collective idea of many people.

In general, fast really means "less time". But in more general terms, what you are really after is less mistakes and less distractions. So instead of thinking of "fast" as an external thing that we have little control of, I tend to think of fast as any method that improves the overall way that I work and function, that is particular to me.

If it normally takes me 1-hour, let's say for example, to create and to style a webpage for a client demo, then I would tend to see if I am making the best use of that hour. Or if I spent 5 minute chunks looking at my phone, checking my emails and finding just the right song for this hour. All of these things can affect your "fastness".

On that note, learn to be aware of when 'fast' is appropriate. On more complex tasks, fast might hurt you more than help you in the long haul. Or it might take on different meanings depending on what you are doing. Are you actually typing fast, or are you building bug-free and complex code logic fast?

Improve your typing speed

This is the quickest route that you can take in improving your overall coding speed. There is a huge difference in someone that types at 40WPM vs someone that can type at over 100+ WPM. Not only more characters per minute to dish out, but because you are flowing faster through blocks of logic, you have less time to second guess yourself and it becomes easier to get into that workflow state. Once touch-typing becomes second nature, you will also spend less energy in trying to figure out where certain keys are located. Because that does require micro-adjustments in your focus each and everytime you do it.

As not so scientific proof, if you were to see my Dad type on a keyboard, you could see the level of concentration that only a skilled marine might face during a time of combat. Each key he types is more painful than the last and his eyes wander from left to right in an endless battle of wits. Everything we do requires energy, it just does. You can't lift your arm or move a finger or shift your eyesight without it.

So this becomes subjective to each person. Where are you comfortable typing is the question. I myself fall somewhere around the 80-100 WPM mark and can function relatively well there without having to take on daily touch-type practice. Essentially, that speed works well with my current flow and the demands of my work. But there are people that can type much faster than that and they can do so at a high accuracy rate and just overall have much higher brain throughput.

You might also be under that number, but still be able to function well with your current skillset. So it is important to gauge how you feel about your typing speed.  I've met plenty of people who type 1-keystroke at a time with both hands and they can obviously tell that this is going to be a problem in the long term. Being aware of the issue is step 1, before we can begin to make corrections.

Prepare ahead of time

Abraham Lincoln was once quoted as stating "Give me six hours to chop down a tree and I will spend the first four sharpening the ax". Wise words. As with anything in life, the more prepared you are, the easier things tend to flow. If you know what needs to get done, then that is half the battle. You will make corrections and steer yourself around as you progress, absolutely, but you won't lose sight of the target, which is where many programmer's find themselves struggling as they type and type for hours essentially a moving target.

Prepare for your code by having a very quick outline, in your native language, of what needs to get done. Quick, but be thorough. Write until you reach a destination point for your project. I tend to use pen and paper for this, as it allows me to make quick corrections along the way with minimal interruptions to my workflow.

If I make notes on my tablet for example, then normally I have to switch over to various tabs and windows. And while we do this all day long without a care in the world, it has been shown in research that it takes a considerable amount of time to bring our focus back onto a task when we shift our attention in such a way.

Gloria Mark, professor in the department of Informatics at the University of California, Irvine, says that when people are interrupted, it typically takes 23 minutes and 15 seconds[3] to return to their work, and most people will do two intervening tasks before going back to their original project. Don't take her word for it and experiment. Turn your phone off for an hour and only have 1 tab open for the current task at hand. Then do the same task with your phone on and the usual dozen tabs and windows open while playing music and eating lunch. And analyze the work output.

So having a prepared roadmap of your work is going to save you a fair amount of time when it comes to your overall daily focus, which will effect your speed of performance.

Framework your code

This has been the overall best method when it comes to reducing my total coding time. If any amount of code needs to be copy and pasted somewhere on your project, there is a good chance that you will need to use this further down the pipeline, either in the same project, or a different one perhaps. In which case, you should probably spend the extra time and build out your own coding framework. Not only does it reduce the overall coding/typing time, but the maintenance time as well. Having one generalized repository of code means that you only need to update that bit of code one time, instead of tracking down the many different places where you might have placed it.

This will be unique to your skillset and your programming language of choice of course. If you are a .NET developer, then you can check out my post here on how I implement my particular framework and have done so for years now. And if you are familiar with other languages and frameworks, then really you'll want to explore a bit and see how you too can keep your code in an easy to store and easy to use place. Easy for you mainly, and not for someone that wrote about it online.

This process looks slow in the beginning, because it requires you constantly maintain another codebase, but believe me, in the long term it will save you phenomenal amounts of time. And I speak from experience and as someone who has spent 10+ years building out a generalized framework for building web applications and non-web applications.

Much of the code that I need to write today is delegated to my framework. So much so that I have plentiful energy to focus on the task at hand and the business applications and less time on the tedious and repetitive code that take up minutes to hours.

In closing

There is no real magic trick to getting code out any faster than you are capable of. But there are habits that we tend to have that will slow down progress, and we all have them. Things such as assuming that we can't type any faster and not making it an effort to learn. Or not taking out a pen and paper and sketching out ideas. These sound like simple tricks and techniques that might have a slight impact, but if you look at the cognitive science behind them[4], they can have massive impact on your overall coding abilities.

Reducing as many of these distractions as possible, and taking on good solid habits will help to bring some hours back into your life, which you will undoubtedly spend on writing even more code.

Walter Guevara is a Computer Scientist, software engineer, startup founder and currently mentors for a coding bootcamp. He has been creating software for the past 15 years.

References

Discussion / Comments / Questions

No messages posted yet

Add a comment

Send me your weekly newsletter filled with awesome ideas
Post comment