Preface of the translator: After reading this article, you may be surprised or even angry. Yes, we were also surprised: as if the author had never heard about the hierarchy in the team, about setting tasks with the status “done quickly and without reasoning”. Yes, everything is so, it is a bit strange text. Indeed, the author suggests that the programmer take on the role of a system architect — and then why do you need an architect? But all these objections should not cover the main thing from you - why we still took and translated this text. He's not about the role. This text is about professional approach and awareness. The truth is that as long as you simply “do what you say” without thinking about the meaning of your actions, you will never become a big programmer.Say "no" to the extra code. All you have to do is put together three letters and say the word. Let's try to do it together: “Noooooo!”
')
But wait. Why do we do this? After all, the main task of the programmer is to write code. But is it necessary to write any code that is required of you? Not! "Understanding when not to write code is probably the most important skill for a programmer."
The Art Of Readable Code .
We remind: for all readers of "Habr" - a discount of 10,000 rubles when writing to any Skillbox course on the promotional code "Habr".
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 a job started as soon as possible, we don’t think about anything except accomplishing the task. And this can cause even more serious problems.
What do programmers turn a blind eye to?
All code that you write should be clear to 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 modifying old code. The bigger it is, the higher the likelihood of an error and the more time it takes to compile. It takes another developer more time to figure it out. And if you need refactoring, then you will definitely find fragments that should be changed. Volumetric code often means reduced flexibility and functionality of the project. A simple and elegant solution works faster than complex code. ”
How to find out when to not write code?
The problem is that programmers often exaggerate the number of functions needed by their application. As a result, many parts of the code remain incomplete or no one uses them, but they complicate the application.
You must clearly understand what your project needs and what does not.As an example, an application that solves only one task - manages e-mail. To do this, two functions have been introduced - sending and receiving letters. Do not expect the mail manager to become a task manager at the same time.
It is necessary to firmly say “no” to the sentences to add functions that are not related to the main task of the application. This is exactly the moment when it becomes clear that no additional code is needed.
Never knock down the focus of your application.Always ask yourself:
- What function should be implemented now?
- What code is worth writing?
Challenge ideas that come to mind, and evaluate suggestions from outside. Otherwise, the extra code can simply kill the project.
Knowing when not to add too much will keep the code base under tight control.
At the very beginning of the journey, the programmer has only two or three source files. It's simple. Compiling and running the application takes a minimum of time; it is 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 is becoming more and more difficult to remember which functions are responsible for what and which actions they cause; catching bugs also takes more time. Complicated and project management, it takes not one, but several developers to keep track of everything. Accordingly, expenses, both monetary, and temporary grow, development process is braked.
The project eventually becomes huge, adding each new function is given with great difficulty. Even something insignificant has to spend several hours. Correction of existing errors leads to the emergence of new, deadlines for release of the application.
Now we have to fight for the life of the project. Why?
The fact is that you simply did not understand when you do not need to add extra code, and each sentence and idea was answered "yes." You were blind, the desire to create something new made you ignore important facts.
Sounds like a horror movie script, right?
That is what will happen if you keep saying yes. Try to understand when the code is not worth adding. Remove unnecessary from the project - it will make your life easier and will prolong the existence of the application.
“One of my most productive days is when I deleted 1,000 lines of code.”
- Ken Thompson.
Learning to understand when not to write code is difficult. But it is necessary.
Yes, I know that you have just entered 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 the important factors due to enthusiasm. We realized everything through trial and error. You too will 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: