6 useful habits that, surprisingly, only a few programmers have

If you think about what qualities are characteristic of someone who can be called a "good programmer", then some habits will immediately come to mind. Such habits, which most developers agree with, are very useful. But, in fact, most of these developers themselves do not have such habits.

As we all know, habits determine our lives. Anyone who wants to grow above himself in the field of programming needs to try to form appropriate habits in himself. I propose to talk about six habits that you should try to form for yourself to someone who wants to stand out from the gray crowd.





1. Clean up the code you are working with


It is useful for any programmer to form a habit of improving the code that he has ever had to change. It doesn’t matter if it is about fixing a single line of code, or about adding a whole new subsystem to an existing project.

Robert Martin made one valuable point about this. He calls it the "scout rule." It sounds like this: "Always leave the code you are editing in a cleaner state than it was before you."

You will be amazed at how many little things you can improve when you just read some kind of code. The changes you make to the code can be quite minor - like renaming a variable or function. Just try whenever possible to improve at least something. As a result, the code after you will look better, it will have fewer obvious problems.

This habit is extremely useful to have because it means continuous learning. What we considered good yesterday can be improved today by redoing it in some new, more successful way. Over time, the code has the ability to "deteriorate", so taking care of the code is extremely important to keep it in a state in which it is convenient to maintain.

2. Take care of those who will work with your code after you


Whenever you write a code snippet, you should think about what someone else who sees this code will see.

Write code so that it is readable so that it is easy to understand. The ratio of the time that is spent reading and creating code is much more than 10 to 1. This means that, in the long run, you can save a lot of man-hours just by making more efforts to write readable code.

When programming, do not strive for all sorts of "tricks." Write a simple code that will be understandable to anyone who reads it. Agree, there is usually no real need to use the mysterious single-line copied from Stack Overflow, which you yourself do not really understand.

3. Do what you need, but no more


Developers have a peculiar habit of unnecessarily complicating and expanding what they do. Most developers, faced with the task of realizing a certain opportunity, will do, “just in case”, something beyond what they should.

This is what is called "over-engineering" - the "art of overdoing." The code is made more reliable or more complex than necessary. Overeengineering is something for which there is no good reason.

Most often, the reason why developers create more complex programs than required is based on conjecture. For example, a developer may add code to a project that may be useful in the future. This is done only on the basis of the assumptions of this developer. This additional code falls into the code base of the project, but it is quite possible that it will never be useful to anyone.

Overeengineering can lead to the appearance of code that is designed in such a general way that it will lose the characteristics of the main task for which it was originally intended. As a result, such a code will not only be difficult to use. Such a code would also be very incomprehensible.

4. Plan your code.


Real programmers like to do one and only one thing: programming. This should not surprise you. Given this, it is obvious that most programmers, when given the task, are immediately taken for their favorite job. They immediately start writing code.

At first, the idea of ​​going into the code with your head might seem amazing. But for this "admiration", it is quite possible that you will have to pay with time. When a programmer, without hesitation, rushes to write code, he, in the end, ceases to see the big picture.

Before you start writing a program, you need to plan and organize everything. It is worth thinking about the difficulties that may be encountered along the way, and how to solve them. It is useful to reflect on the structure of the code, on why it is planned to implement this or that feature of the project.

All of these are great questions to ask before starting work on the code. These questions will give you the opportunity to realize that before you write code, you can and should think about a lot.

5. Document your projects


I know - documenting code is not the most attractive habit on this list. But this is a very, very good habit. Writing documentation is very important.

Have you ever come across a repository in which there is no information about how to configure everything correctly, or how the application located in this repository should work?

After you spend a couple of hours reading the code stored in such a repository, it is likely that you will not understand anything. That's when you feel the value of the documentation.

The absolute minimum documentation that I would recommend equipping any project is an adequate file readme.mdthat tells you what this project is for and how to properly configure and run it.

In the field of documenting software projects, there is one remarkable phenomenon. It consists in the possibility of documenting the code in the process of writing it. Give yourself some time to come up with descriptive variable names. It will pay for itself. Choosing good names for variables, methods, and classes takes time. But good names will save more time than you need to invent them.

If you are interested in the issue of selecting meaningful names for various entities - take a look at this material.

6. Never stop learning


Isaac Asimov said: "The day when you stop studying, this is the day when you begin to degrade." These words are especially true for the world of computer technology, in which everything changes very quickly.

It is impossible to keep up with everything that is changing, and even if someone is capable of this, I would not advise striving for this. You should not take this desire to the extreme, but it is useful from time to time to learn a new framework or programming language.

This does not mean that you need to become an expert in all such frameworks or languages. It is useful to experiment with something new to find out if you like it.

Studying new things, the programmer sees how various tasks are solved using tools that he did not know about before. This helps him grow professionally.

Summary


Anyone who strives to become outstanding programmers can go towards this goal, developing many different habits. Here we have examined six habits that most developers do not have.

Here are some tips on building good programming habits:

  • Clean up the code you're working with.
  • Take care of those who will work with your code after you.
  • Do what you need, but nothing more.
  • Plan your code.
  • Document your projects.
  • Never stop learning.

Try to develop these habits. Do not rush, develop them yourself gradually, one at a time. Remember that in one day you do not get them. In order to develop habits, you need time and consistency.

What habits of good programmers would you add to those discussed in this article?


All Articles