Write bad code, you can't replace it in the company?

Many classmates joked, "If you write the code badly, you can't replace it in the company." In fact, everyone knows that it is impossible. Once Fatty and his colleagues spent a week just to refactor an extremely complex method that is simply obfuscating the code, so don't underestimate the company's determination to refactor the code. So how to avoid some low-quality code in the project.

Pull Request

In fact, we can learn from the code management of open source projects. In addition to constraining contributors by declaring some protocols, open source projects also use Pull Request to collaborate.

Pull Request

Code contributors need to initiate the merger of the request, the project manager will be designated auditors requested merge the code of Review .

If unreasonable places are found, they will be marked and fed back to the contributors; at the same time, the testers will also test the code. If the code has quality problems, it will be beaten back for improvement, and can not be merged until it is compliant, so there are ways to treat "bad" code.

QA tools

In addition to collaboration, we can also use some tools to check the quality of the code. The biggest difference between humans and animals is that they can use tools. Going to the review line by line is very laborious, so some static code detection tools were born, such as findbugs , checkstyle and other tools to correct our bad habits. Later, code appeared. Quality management platform to ensure the code quality of large projects, such as the well-known SonarQube , even code quality inspection has been embedded in the continuous integration process, when the developer initiates a submission, it will track and report the defects in the code.

SonarQube dashboard

There are various indicators to track the quality of your code. Do you still want to submit "bad" code?

How to improve code quality

I am often asked this question. The only way to improve is to write more. Many students like to watch videos and watch tutorials, but they just refuse to write a demo. Be sure to write more and analyze more, use tools to scan for defects, refine your code repeatedly, and strive to improve the sense of hierarchy and readability of your code. It is only a matter of time before writing high-quality code.

This feature of IntelliJ IDEA is really easy to use

2021-03-30

I've been busy and improved my JWT implementation.

2021-03-29

Niu batch! Automatically publish jars to Maven central warehouse

2021-03-25

Guess you like

Origin blog.csdn.net/qq_35067322/article/details/115344186