今日推荐英文原文：《3 Coding Stages: Writing. Avoiding. Deleting.》
推荐理由：总有些人喜欢瞎问“xxx是什么”这样的问题而不会选择自己去百度或者 google 上搜一下，更何况这些问题绝大多数搜一下都会有个像模像样的结果，所以如果你遇上了这样的人，就可以考虑一下使用这个项目了。你只需要把它的问题输入搜索框，然后把链接丢给他就好了——既然你都真的帮他百度了，他也不好说你什么不是吗？
今日推荐英文原文：《3 Coding Stages: Writing. Avoiding. Deleting.》作者：Huseyin Polat Yuruk
3 Coding Stages: Writing. Avoiding. Deleting.
Writing code is just the tip of the iceberg
IcebergThis is how I see all the hidden facts that we developers usually forget or tend to ignore when we are excited about writing code or implementing something new. In the form of an iceberg…
The iceberg looks small and beautiful from the outside, so people tend to forget its actual size and what hides beneath the peak. What people see from the outside is actually just the tip.
Writing code is the same thing.
When you start writing code, you are too focused on what you have to write, and you don’t focus on how much it may cost you down the road. Or, you ignore it.
As the years pass, all your experience and the mistakes you make teach you that what you used to ignore is actually the most important thing you must consider.
So what are those important facts that, as a developer, you usually forget?
Every line of code you write is:
- code that has to be read and understood by other programmers
- code that has to be tested and debugged
- code that will increase defects in your software
- code that probably will introduce new bugs in the future
In a developer’s programming life, it takes some time to develop the ability to see the whole of the iceberg. To see that, you have to pass through the three coding stages in your programming life.
Let’s speed up time and check each of the stages together.
1. Writing code as much as possibleRemember this time? You had just started your programming career as a junior developer. You were hungry, foolish. You were always on the lookout to write some more code lines and for problems to solve. You said yes to every possibility that required you to write code. You were too excited. You spent hours and days on it. You forget about sleeping.
Being too excited and writing code as much as you can in that stage is good. This is how it should be. This is how we learn to program. This is how we practice being a better developer. In the meantime, while we are writing that bunch of code, we make a lot of mistakes too. And that is totally fine. They are just small mistakes. Nothing can stop you from writing code.
After some time, maybe four to five years, you start learning the new programming facts that you didn’t know before. You face the reality beyond the code. You have just seen the tip of the iceberg with writing code, and now you are curious to see what is under the sea.
This is the stage where you see that every code has to be read, understood, tested, debugged. You’ve just understood how important future maintenance is for your software to last longer.
2. Learning when not to write codeAfter you experienced a few programming horror stories, you found yourself thinking about how you can avoid writing unnecessary code, because you knew how much it can cost you.
In this stage, you were learning when not to write code to avoid being a victim of another horror story. You were still excited about writing code, but you were wise enough to know that less code is better. Simplicity is your ultimate guide here. You understood that it’s harder to read code than to write it. That’s why you started focusing on more readable, understandable, and simpler code.
In this stage, you followed a few simple rules that transformed you into a better programmer.
- Writing less code.
- Keeping your codebase small
- Saying yes to what is essential and saying no to rest of it
Knowing when not to code is possibly the most important skill a programmer can learn. — The Art Of Readable Code
3. Deleting code as much as possible
One of my most productive days was throwing away 1000 lines of code. — Ken ThompsonIn this stage of coding, you understand exactly what Ken Thompson was trying to say with the above sentence.
You know that the more code you have, the more places there are for bugs to appear. It takes longer checkouts or compiles. It takes longer for a new employee to understand your system. There’s more stuff to move around if you have to refactor.
Furthermore, more code often means less flexibility and functionality. You understand it based on your own experience. You know when not to code, but, at the same time, you know that by deleting the unnecessary codes or refactoring complex solutions with simpler, more elegant ones, you can decrease defects in your software.
In this stage, you discovered all parts of the iceberg. You know what is under the sea. The next time you see a new iceberg, you will be more careful, and you will not make the same mistake as the Titanic did.
The key idea of this piece is not that writing code is your enemy. You are a programmer. Writing code is your passion and it will always be. It will cover a big part of your life. I just want you to understand what is behind all of that code writing, and that with each line of code you have written, you accept the burden that comes along.
Don’t surround yourself with unnecessary codes.