Write less code

2012/07/20 08:23
Reading 361

One of the basic facts of software development is that you need to write code. But one of the biggest misconceptions is that "writing code is my job". When I started my career as a software developer, I fell into this misunderstanding.

The code is powerful. It can let you do many things. You feel that you are efficient and that you have completed the work. Then, over the years, I learned the true nature of things: The essence of a programmer's job is to write as little code as possible

Don't misunderstand me. I'm not saying that we should compress the code in order to try to hit the keyboard as little as possible, so that the written code can't be understood at all. When you think of the fact that, as a programmer, you will spend most of your time maintaining the terrible code you write, you will feel that "write less code, Don't let your code add more work to your workload ”This principle is a very good idea.

Why?

Think about your job. Think about the tools you use and the frameworks you like to use for development. Everything you do, every tool you use, is designed to make you write less code. Your tools can help you make fewer mistakes and abstract out the underlying details that may cause you trouble.

So why do you need to write less code? As I said earlier: Your job is to write less code In fact, I didn't tell the truth. Your real job is to think.   Your job is to think about the problem to be solved, design an elegant solution, and then turn this solution into software. A by-product of developing software is that you need to write code to solve problems

* Code is a by-product*

The code is not that important. The reason why we like to think that way is that when we start to work and turn solutions into code, writing code seems to be both a means and an end. We talk about the editor we use, the programming language we use and our programming environment. I have done this, you have done this, we have done this. Admittedly, there is nothing wrong with enjoying the happiness your work brings you, but you should realize that, Code is great, but it is also your enemy: it takes you a lot of time to write code, it may have various bugs, it may be difficult to understand, or not elegant enough

That's why I insist“ Write less code ”Reason for. When I think something becomes more complicated than necessary or more complicated than it originally looks, I tell myself to "write less code". When I write too much code to understand it in context, I refactor, clean up, and insist on "writing less code".

Although it pains me, I have to say that sometimes writing a lot of code is unavoidable. But when you can't keep it simple, keep it clear.   "Write less code" is to write clean code and clear code When you write concise enough code, the purpose of your program becomes clearer.

So, what is the experience of this lesson? I think the most important thing is“ Code is just a by-product ”, It is something that you will inevitably create in the process of your work. Therefore, think more, refactor more, get rid of some old code, and write less new code , give yourself a chance, starting today.

Original English: Write Less Code

Chinese translation: Write less code

Expand to read the full text
Loading
Click to lead the topic 📣 Post and join the discussion 🔥
Reward
zero comment
three Collection
four fabulous
 Back to top
Top