The best code is no code at all "No (generation) code wins (generation) code"

Source: Internet
Author: User
The best code is no code at all
None (generation) codes win (generation) Codes

From: http://www.yeeyan.com/articles/view/welovecs/1590
Code often causes headaches. It will gradually corrupt, and it needs to be regularly maintained. It has endless bugs that need to be discovered urgently. When new features emerge, we need to tailor the old code. The longer the code we write, the more bugs there are. The longer the code syntax check or compilation time is, the longer it takes for new employees in the company to understand the system we have written. Intelligent, you may think of code refactoring, but the problem is: the reconstruction code is like the waves in the Yangtze River.

 

Code is the crystallization of the wisdom of software engineers. More code requires more engineers. However, the cost of communication between engineers is proportional to the number of engineers. Adding new code to an existing system. Although the system functions are extended, the production cost is greatly increased. We should "do nothing" to improve the productivity of individual programmers so that they can write code with good expressiveness. Use shorter code to implement the same (more) functions, build the same system with fewer engineers, and reduce communication costs, achieving the same project should be our goal.

Although Rich is bad in code, its "intoxicating meaning" is not in code. The code written by software engineers in the code editor is like a cute new baby. It is innocent and repeatable. In fact, code is not our enemy. Do you want to know who the real enemy is? Look in the mirror. What do you see? By yourself, that's the problem.

 

As a software developer, our greatest enemy is not others, but ourselves.

The sooner we recognize this, the faster we grow.

 

I know that even if you write redundant code, your intention is good, and everyone is the same. We are software developers, and we love programming. We have never encountered the inability to use pipe tape (duct tape)[1], A temporary hanger (jury-rigged coat hanger) or a small amount of code (a pinch of code)[2]Solve the problem. However, Wil Shipley holds another point of view:Software engineers should control the natural tendency to "write more code".

 

For a programmer, the essence of coding is that every decision we make in the coding process is the result of trade-offs and trade-offs. A master programmer can see the essence of the decision made after the trade-offs. He can also realize that every line of code we write has their shadows.

 

In the coding process, we can evaluate the quality of the code from many aspects:

 

  • Simplicity
  • Rich features
  • Execution speed
  • Coding duration
  • Robustness (robustness)
  • Flexibility

 

Note that these aspects are conflicting. For example, it takes you three days to write a very beautiful and efficient subroutine. You can say that two of the above six aspects are doing well. However, it takes three days for you to take the encoding time.

 

So the question comes out: What aspects are worth doing well? How should we make a choice? A wise, simple, and innovative answer is:Coding focuses on simplicity at the initial stage, and then other aspects will be done according to the test requirements.

 

Wil Shipley says it is definitely. InCode smallerIn this article, I gave similar suggestions. I am not saying: we should stick our brains and use the skills in books to reduce the size of code. What I want to say is: a practical and easy-to-understand strategy. By implementing this policy, we can reduce the size of code that individual programmers need to read to understand the program running mechanism. Below is a small example I will discuss:

 

If (S = string. Empty)

If (S = "")

 

In my opinion, the last line of code is obviously better, just because it is more concise. Speaking of this, I can assure that some developers have objections to my statements. What's moreArgue with me. Because they fully believe in lengthy string. Empty, to some extent, is compiler-friendly.

 

For most software developers, it is painful to acknowledge this. They love programming, but, as the topic in this article says, "No code is better than no code. Each line of code we plan to write must be debugged and read by other developers. They must be maintained and supported. Therefore, every time you write new code, even if there are one hundred reluctant users, even if they feel forced, please make the code concise. You have no choice, because the longer the code, the more likely it will be your enemy. We cannot do "write no code", but we can at least focus on the simplicity of the code at the initial stage of coding.

 

If you really love programming, I'm sure you will also like concise code.

 

------------------------

Note:

[1]"Perl is the duct tape of the Internet."-Hassan Schroeder, sun's first webmaster.

"Perl is the pipe tape of the Internet. "-Hassan Schroeder

[2]I don't know what it means--. I hope you can tell me what it means. Thank you.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.