Today, I was browsing the social network and suddenly found a very interesting post, "What does it feel like to have written 1 million lines of code?" My scalp went numb after reading this. You asked me to write 10,000 lines of code?!are you kidding me? (black question mark face) I guess when I write 200,000 lines of code, I will suddenly have a question - "Huh? Where is my hair?" Student A: I have to spend two or three days to think about the function of 2,000 lines of code. One million lines is really a lot. In five years, I have written only about 200,000 to 300,000 lines of code at most, and I was forced to write because of the tasks. If I were asked to write one million lines of code, I would probably die in front of a computer in this life... Student B: I think if you write a million lines of code for a job, then you should be considered a senior employee in the company. If you write a million lines of code for a project, then you must have participated in a relatively large project. If you wrote a class with 1 million lines, what editor did you use? If you wrote a method with 1 million lines of code, did your colleagues beat you to death? Student C: It is said that to grow from a beginner to a programmer, you need to accumulate 100,000 lines of code. But it is true, after all, in the introductory stage, you really need to write more code to accumulate experience. However, it would be wrong to focus on the amount of code after practicing for a period of time. At this time, you must focus on mathematics and algorithmic thinking. According to this calculation, if 200,000 is the threshold for practice, and you have really accumulated one million lines of code, the quality of the code will definitely become higher and higher, and you may even be a small expert in a certain field. As for the fact that you have really typed a million lines of low-quality code, listen to me and change your career. Programmers are not suitable for your perseverance. Student D: Tsk, what a bunch of scum. Let me show you a picture on the Internet to show you what it's like to stay up all night writing thousands of lines of code. I feel like I'm about to suffocate. If time could go back, I hope I wouldn't be a programmer!!! Student E: This is simply a gift of death. How can anyone write a million lines of code? A programmer who has been in the industry for five or six years can only write more than a hundred lines a day at a normal workload. In these five or six years, it is estimated that he can only write 50,000 to 60,000 lines. If the code volume of the outsourcing company is estimated to be doubled, then we can calculate it as 500,000 lines. But who would work so hard to work on the front line with a thousand lines a day? Those who write 500,000 or 600,000 lines must have switched to starting a business, and if they continue to work, they will probably die suddenly or lose a layer of skin. In fact, the quality of code is more important than the quantity. High-quality code is advocated by the current code community. Of course, writing high-quality code definitely requires a fairly high level of professionalism, which needs to be gradually absorbed and mastered in daily code writing. Who doesn't learn every day? The purpose is not to write high-quality code to achieve a certain function. So, how long does it take to write 1 million lines of code? Let's do the math: Assuming the worst case scenario, 100 lines of high-quality code a day, 36,500 lines a year, 100/3.65 = more than 27 years. Even if you start coding at the age of 20, you will not be able to finish until you are around 50 years old. But in fact, regarding the average amount of code, even if all working days are counted, it is probably about 20-30 lines; if we only discuss the concentrated development period, the peak will not exceed 200 lines. So, a million codes is as unreliable as finding a girlfriend. To summarize: Regarding the amount of code, growing from a beginner to a programmer requires the accumulation of code, and deepening of mathematical skills and programming thinking will become more important in the future. Pursuing quantity blindly does not make any practical sense . Usually, the more core the part, the smaller the code volume. It is easier to write a lot of code, probably UI and business logic, which do not require much technical content. Some parts can be more concise by using scripts or DSL. Writing code is like taking an exam. The one who does the most questions does not necessarily get the best score. In addition, if you want to write high-quality code, it is recommended to lay a good technical foundation first, such as mastering the development language, being familiar with the development platform, mastering the basic data structure and algorithm, and understanding the basic design principles. It is recommended to adopt code standards, such as Google and other large companies have already formulated various standards. Think before writing, it is not recommended to think while doing. It is often difficult for us to write code that satisfies us and is impeccable in one go, so the importance of refactoring to code quality is self-evident. I recommend reading the industry classic book "Refactoring". Many problems are ultimately technical debts. As far as code quality is concerned, if you still pursue high-quality code, it is recommended that when you are responsible for a small module, in addition to doing it well, you should also pay off the technical debts that are entangled with it. No one in a team can be immune to this. Code review is also essential for writing high-quality code. In fact, many code problems can be found through some tools. For example, in Android development, there are excellent static checking tools such as Lint, Find bugs, PMD, etc. By improving the problems found by these tools, you can have a more intuitive understanding of the details of syntax, specifications, and programming skills. It is recommended to use it in conjunction with continuous integration (CI) and a code review environment. Each code submission can be automatically verified to see if it has passed the tool's code check, and submission is allowed only if it has passed. When you need to modify a large amount of code, the advantages of unit testing will emerge. You can modify it without worrying about whether the unit test cases pass or not. After writing the code, do a full self-test. You need to run at least the basic scenarios and some simple exception flows. Don't always expect the test to help you find problems. *** is to make good use of open source. Although not all open source things have high quality, at least the open source projects with high attention, large number of users and good reputation have a certain guarantee of quality. Even if there are some problems, they can be continuously improved by submitting feedback. The most important thing is that the wheel you built yourself requires a lot of energy to maintain, and making full use of open source projects can help you save a lot of time and focus your energy on the issues that need your most attention. |
>>: I can't write MVP architecture after reading it. I'm kneeling on the washboard
Failure to pass the review and lack of traffic ar...
Do you know which stage of community operation yo...
In recent years, Apple has been unable to convinc...
Recently, many of my friends came to me worriedly...
Many business leaders often ask us: We have carri...
Online education has developed rapidly in recent ...
As the epidemic situation eases, many areas have ...
What happened to the Wuhan University internet-fa...
There is no doubt that Tik Tok is so popular that...
At noon on November 20, the Tencent WeChat team c...
After nearly 20 years of development, the three l...
There is actually no shortcut to planning an even...
Original title: "Ask the reporter·Fun facts ...
Many people did not expect that the extended-rang...
Recently, many businesses have just come into con...