The Secret to Quick Programming: Don't Think

Original author: Max Kanat-Alexander
  • Transfer

Programming fast is easy! So says Google's software engineer, who signs all publications on his blog with a concise "Max." Max also works as chief architect, community manager, and release manager for the Bugzilla Project . We at Alconost were impressed and translated his advice on how to learn how to learn how to program at space speed.

When discussing code complexity with developers, they often say that they want to write simple code, but due to pressure from deadlines and deeper reasons, they don’t have enough time or knowledge to complete the task and optimize the solution to the maximum simplicity.

They, of course, are right that in the conditions of tight deadlines, developers, as a rule, will write complex code. However, deadlines should not lead to complexity. Instead of the phrase "This deadline prevented me from writing simple code," you can say the equivalent: "I'm not fast enough to program to write simply." That is, the faster you as a programmer, the less influence the deadlines have on the quality of your code.

Now let's figure out how, in fact, to become faster? Maybe this is an innate magical skill? Does one have to be smarter than others in order to be quick?

No, this is not magic at all and not an innate gift. In fact, there is only one simple rule, reckoning with which, over time, you will completely solve the problem:

Whenever you notice that you are stomping around in thought, know that something has gone wrong .

It may sound incredible, but it works exceptionally well. Think about it: when you are sitting in front of your editor, but the work is not fast, is it because you have low typing speed? I doubt: “typing too much” is a rare problem in programmer productivity. Pauses when you are not dialing are what slow things down. And what do developers usually do in such pauses? They are trying to stop thinking - maybe about a problem, about tools, about a message in the mail, but about anything. But whenever this happens, it means a problem. Thinking alone is not a problem, but a sign of some other problem. Probably, instead of walking in circles in your thoughts, you should pay attention to one of these:

Understanding


The most common reason for a developer’s unproductive thought is an incomplete understanding of a word or symbol.

This happened to me just the other day. It took me hours to write what was supposed to be a really simple service. I tried very hard to stop thinking about it, trying to figure out how everything should work. As a result, I realized that I did not understand one of the input variables in the main function. I knew the name of its type, but I never asked about its definition - that is, I really did not understand what this variable (word or symbol) meant. As soon as I looked at the code and documentation for this type - understanding came, and I wrote this service as a daemon (a pun is partly nonrandom).

There are countless such options. Many people use the programming language, not understanding what (,), [,], {,}, +, * and% mean in this language. Some developers do not understand how a computer actually works. Remember my " Rock Star Programmer 's Only Secret "? That's where the point is! After all, if you truly understand, you do not need to stop unnecessary thoughts. It also prompted me to write a book : understanding that there are unshakable laws for creating software can save many episodes of the “fight against reflection” episodes.

So, if you find yourself in a mental impasse, do not try to solve the problem in your head - look for something that you do not understand, outside of yourself. Then take it and seefor something that will help your understanding. This applies even to questions like “Will the user ever read this text?” You may not have a Department of User Experience Research for the real answer to this question, but you can at least draw something, show others, listen to their opinions. Do not try to just sit and think - do something. Only action leads to understanding.

Painting


It happens that a developer’s thought stops because he cannot simultaneously keep in his head all the ideas that are in the work — a lot of things connected in a complex way that need to be understood. In this case, it is almost always more efficient to write or sketch something than to think about it. You need to somehow look at it from the side, to perceive outside your head. This is one of the options for understanding, but important enough to make it a separate point.

Getting started


Sometimes the problem is that "there is no idea what code you need to start writing." The simplest solution is to start writing any code you know that you can write right now. Select the part of the problem that you fully understand, and write a solution for it, even if it is just one function or not the most important class.

Often the code snippet that’s easiest to start with is the core of the application. For example, if I were to write a YouTube application, I would start with a video player. Think of it as a continuous delivery exercise: write code that really creates the product first- no matter how stupid or insignificant it can turn out. A video player without a user interface is already a product that performs a useful task (video playback), even if it is not yet complete .

If you are not sure how to write even such basic code, just start with the code you are sure of. Usually, as soon as part of the problem is solved, it becomes much easier to solve the whole problem. Sometimes a problem is revealed in stages: you solve one part, which makes the solution to the next part obvious, and so on. Start with any part that doesn’t require much thought to create, and just write it.

Skip steps


Another specific problem of understanding is to skip a step in the correct development sequence. For example, our Bicycle object depends on the Wheel, Pedal, and Frame objects. If you try to write the entire Bicycle object without writing the Wheel, Pedal and Rama objects, you will have to think a lot about these non-existent classes. On the other hand, if you write the Wheel class, while the Bicycle class does not exist at all, you have a lot to think about how the Wheel class will be used by the Bicycle class.

The right decision here is to implement a sufficient part of the Bicycle class to get to the step where you need the Wheels. Then write enough of the Wheels class to satisfy the current need for the Bicycle class. Then return to the Bicycle class and work on it until the next need for some of the basic elements. As in the “Getting Started” paragraph: find the part of the problem that you can solve without thinking, and solve it right away.

Do not skip steps when developing your system - and this will allow you to be productive.

Physical problems


If I do not eat enough, I begin to get distracted and think because I am hungry. Not all of them will be thoughts of my stomach, but they would not have arisen at all if I had been full — I would have been focused. The same is true for sleep, illness, and any other bodily problems. They are not as common as the ones listed above, so the first thing you should always look for is that you do not understand well enough. But if you are sure that you understand everything , the reason for stopping thoughts may be problems on a physical level.



Distractions


When a developer is distracted by something external, such as noise, he may need to think for a while to remember what he was working on in his decision. The answer here is relatively simple: before you sit down for development, make sure that your environment does not bother you or that distractions will not interrupt you. Some need to close the door to their office, others need to put on headphones, someone need to set the status to "Do not disturb": do as you need. You may need the help of your manager or staff to create a truly development-friendly environment.

Self-doubt


Sometimes a developer sits and thinks because he feels insecurity about himself and his decisions. The solution here is similar to that described in the Understanding section: if you are not sure of something, find out more about it until you have enough confidence to write the code. If you are unsure of yourself as a programmer in general, you may need to learn a lot more - like the basics outlined in “ Why Programmers Sucks ”. Deal with each question until you have a real understanding, then move on to the next, and so on. Programming always involves learning in the process, but as your baggage of knowledge increases, you will become faster and faster, and you will have to think less and less.

False representations


Many have been told that thinking is the destiny of smart people, and they do not think to make rational decisions. But this is not true. If thinking alone could make you a genius, there would be only Einsteins around . Truly smart people learn, observe, make decisions and act. They acquire knowledge and then use it to solve emerging problems. If you want to be really smart, use your intellect to work in the physical world - do not lock yourself with it for great thoughts in your head.

Inaction


All of the above is the key to being a fast programmer when you sit and write code . If you read the mail all day and go to meetings, and you have no time to program, this is another problem. Some of its aspects are similar (it is as if the organization had to “not think”), but this is not the same.

However, you can try several approaches by analogy. It is likely that the organization does not fully understand you or your roleand therefore sends you so many letters and calls for so many meetings. Perhaps you don’t understand something about the organization, for example, how to attend fewer meetings and receive less mail :) Maybe you can solve some organizational difficulties by adapting solutions from this post to teams instead of individuals.

How do you like this approach?


About the translator
Translation of the article was done in Alconost.

Alconost localizes applications, games and sites in 60 languages. Native-language translators, linguistic testing, cloud platform with API, continuous localization, project managers 24/7, any format of string resources.

We also make promotional and educational videos.- for sites selling, image-building, advertising, training, teasers, expliners, trailers for Google Play and the App Store.

Read more: alconost.com


Also popular now: