Recently and a few fresh graduates chat, talking about the standard of good programmers, improvised a few points. In hindsight, this issue is quite universal, it is worth recording and sharing with you.
Overall, I think there is a clear difference between good programmers and average programmers in four competencies: a habit of unit testing, high code readability, high-quality refactoring skills, and good abstract thinking skills.
1. Unit testing
The basic requirement of a programmer is to complete the code development work and get the code up and running on the right lines. After we try to run it once and get just the expected output, the job is only half done by this point.
This is because there are several other inputs that can give the program incorrect output or output that is not expected by the developer. And the purpose of unit testing is to prove that the program code almost always works as expected under various input scenarios.
Arguably, unit testing is the most important method of moving from the program being correct by chance to the program being correct with a high probability, and is the most basic requirement of a good programmer.
Unit testing is the most typical white-box testing for the Java technology stack, the testing tool is JUnit, which provides a framework for writing test code. The main metric for unit test completion is code coverage, which can be subdivided into line coverage, branch coverage, method coverage and so on.
Coverage statistics are supported by mature tools, such as JaCoCo, through the Maven configuration can be used. Unit test coverage is generally required to be high , in terms of important modules , "line coverage" should be 90% or even 95% or more .
2. High code readability
Many programmers have the misconception that the easier the code is for others to read, the easier they will be replaced. This point of view seems to be logical, but in fact quite hinder personal growth. One of the important things that makes software engineering what it is called is the need for large-scale teamwork.
This collaborative process is required to complement each other. Extreme programming ideology also emphasizes the concept of collective code ownership, i.e., shared ownership and maintenance by the entire team, where any team member can modify any part of the code, improve the code base, and improve the quality of the software.
At the same time, software engineering, like any significant system, cannot but should exist at a single point. If a piece of code is only readable and maintainable by the developer himself, the system is incredibly fragile. Certain poorly readable code, which even the developer himself was able to understand at the time, will be a godsend to himself six months later.
If you really want to protect your career with the idea of poor code readability, chances are you won't be assigned to a major development job.
3. Reconfiguration capacity
Refactoring is an important means of keeping software alive. After a program is born, it is not set in stone. Modifying bugs and adding new features can break the original design expectations. The safest way to do this is to write incremental code by overlaying patches, trying not to modify the main logic.
However, after this approach continues for some time, the framework structure of the code is destroyed, and the various cluttered branches make the program's readability and maintainability plummet.
Refactoring, on the other hand, takes the subsequently generated requirements into account as a whole, and maintains or even improves the rationality of the code framework structure while ensuring that the results are correct. It can be said that being able to accomplish high quality refactoring is the touchstone of a good programmer.
Refactoring requires not only courage, but also methodology. Many programmers don't do refactoring because of its high risk, after all, it is verified in real production environments and stability is guaranteed. Therefore, code refactoring should have full iteration testing as a means of verification, and in order to be feasible in terms of cost, this full iteration must be automated.
Good programmers should consciously accumulate test case scripts during the development process, and be able to perform full-volume iterative testing of functionality through automation. If you are developing a backend application service, then you should accumulate data such as various request messages, response messages and contexts. If there is a well-developed DevOps process in place, it is an organizational-level guarantee of high-quality refactoring.
4. Abstract thinking skills
Program development is faced with many specific problems, seemingly different, need to think about the program from scratch. However, good programmers should be good at abstracting the problem, abstracting the essence of the problem from specific business scenarios, which is a bit like the mathematical modeling process. After abstraction, it is easier to find the classic solution ideas.
As the saying goes, there is nothing new under the sun, and almost all of the problems we face have been dealt with in classic ways. Without the ability to think abstractly, you can only study by yourself or a small group of people behind closed doors, and the person concerned thinks it is a whimsical idea, but in fact, it is a repeat of the invention of the wheel, and this wheel may still be square.
In my opinion, there are two ways to develop abstract thinking, the first is to read more about the design solutions and code of the basic software, because they are not related to the specific business, the technical solutions must have a stronger generality, often compatible with our business scenarios. Or, the solution of application software is basically the method of basic software and then attach the constraints of business scenarios.
The second is to read more top papers in related fields and accumulate solutions to abstract problems, a bit like the masters in martial arts novels practicing internal force, as long as the internal force is strong enough, picking leaves and flying flowers can hurt people. This is the process from abstract to concrete, the beginning of the experience may be slightly more painful, it is recommended to start from the industrial sector papers will reduce the difficulty. From this point of view, abstract thinking is also an important bridge between the real problems in industry and the research results in academia.
To summarize, the four abilities are unit testing habits, high code readability, high quality refactoring ability, and good abstract thinking ability. Behind the four abilities is a reflection of the programmer's self-cultivation, behind the unit testing is a reliable work attitude and professionalism, behind the code readability is a sense of collaboration and open-mindedness, behind the refactoring ability is the pursuit of excellence and the courage of self-iterative, behind the ability of abstract thinking is a solid theoretical foundation and a broad technical vision.