The main skill of the developer who will make your code better

Original author: Hüseyin Polat Yürük
  • Transfer

Translator's Preface: After reading this article, you may be surprised or even angry. Yes, we were also surprised: the author allegedly never heard about the hierarchy in the team, about the setting of tasks with the status “do it quickly and without reasoning”. Yes, that's it, it's a bit weird text. Indeed, the author offers the programmer to take on the role of a systems architect - why then do you need an architect? But all these objections should not hide from you the main thing - why we nevertheless took and translated this text. He's not about roles. This text is about professional approach and awareness. The truth is that while you just “do what they say” without thinking about the meaning of your actions, you will never become a great programmer.

Say no to extra code. All you have to do is put together the three letters and say the word. Let's try to do it together: "Nooo!"

But hey. Why are we doing this? After all, the main task of a programmer is to write code. But is it necessary to write any code that is required of you? Not! "Understanding when you shouldn't write code is probably the most important skill for a programmer." The Art Of Readable Code .

We remind you: for all readers of “Habr” - a discount of 10,000 rubles when registering for any Skillbox course using the “Habr” promo code.

Skillbox recommends: Practical course "Mobile Developer PRO" .

Programming is the art of problem solving. And you are the masters of this art.
Sometimes, trying to get started as soon as possible, we do not think about anything other than completing the task. And this can cause even more serious problems.

What do programmers turn a blind eye to?

All the code that you write should be understood by other developers, as well as tested and debugged.

But there is a problem: whatever you write, it will complicate your software and will probably add bugs in the future.

According to Rich Skrent, the code is our enemy . Here is what he writes:
“The code is bad because it starts to rot and requires constant maintenance. Adding new features often requires modification of the old code. The larger it is, the higher the probability of an error occurring and the more time it takes to compile. Another developer needs more time to figure it out. And if you need refactoring, then there are certainly fragments that are worth changing. Bulk code often means reducing the flexibility and functionality of a project. A simple and elegant solution is faster than complex code. ”

How to find out when you should not write code?

The problem is that programmers often exaggerate the number of functions their application needs. As a result, many sections of the code remain incomplete or no one uses, but they complicate the application.

You must be clearly aware of what your project needs and what not.

An example is an application that solves only one task - it manages e-mail. Two functions have been introduced for this - sending and receiving letters. You should not expect that the mail manager will simultaneously become a task manager.

You need to firmly say no to suggestions to add functions that are not related to the main task of the application. This is exactly the moment when it becomes clear that additional code is not needed.

Never out of focus your application.

Always ask yourself:

- What function should be implemented now?
- What code is worth writing?

Question the ideas that come to mind and evaluate suggestions from the outside. Otherwise, the extra code may just kill the project.

Knowing when you should not add too much will keep the code base under tight control.

At the very beginning of the path, the programmer has only two or three source files. Everything is simple. Compiling and running the application requires a minimum of time; it’s always clear where and what to look for.

As the application expands, more and more code files appear. They fill the directory, each with hundreds of lines. In order to organize all this correctly, you will have to create additional directories. At the same time, it becomes more and more difficult to remember which functions are responsible for what and what actions they cause; catching bugs also takes longer. Project management is becoming more complicated, not just one, but several developers are required to keep track of everything. Accordingly, costs, both monetary and temporary, are growing, and the development process is inhibited.

The project eventually becomes huge, adding each new function is given with great and great difficulty. Even for something very insignificant you have to spend several hours. Correction of existing errors leads to the emergence of new ones, the release dates of the application are disrupted.

Now we have to fight for the life of the project. Why?

The fact is that you simply did not understand when you did not need to add extra code, and they answered “yes” to every sentence and idea. You were blind, the desire to create something new made you ignore important facts.

Sounds like a horror movie script, right?

This is exactly what will happen if you continue to say yes. Try to understand when code is not worth adding. Remove unnecessary from the project - this will greatly facilitate your life and extend the existence of the application.

“One of my most productive days was when I deleted 1000 lines of code.”
- Ken Thompson.

Learning to understand when you do not need to write code is difficult. But it is necessary.

Yes, I know that you have just embarked on the path of a developer and want to write code. This is good, do not lose this first impression, but do not lose sight of important factors due to enthusiasm. We realized everything through trial and error. You will also make mistakes and learn from them. But if you can learn a lesson from the above, your work will become more conscious.

Keep creating, but know when to say no.

Skillbox recommends:

Also popular now: