Code quality is always a pain in our program development, there are many ways to improve code quality, strengthen management is a very common way, here we talk, the so-called management, is really the most effective way to improve code quality?

Is it ok to outsource the code implementation to the team?

Many companies like to system code implementation details in the outsourcing team’s hands, claiming that as long as the product design is reasonable, as long as the structure is reasonable, as long as the code specification is reasonable, the realization of the code to find who achieve are the same, so just find outsourcing team to implement, this should be a lot of Internet companies, especially the thinking of traditional enterprise. But is that really the case? Experienced people should have a deep feeling, outsourcing team development of the code and the company’s internal staff development of the code, there is a great difference in quality, and no matter it is because of the difference in technology itself, vary from person to person, according to the environment, due to the mentality of the code produced by the difference is very different. Software is an engineering product, so what are the characteristics of engineering products?

  • Long term operation and maintenance
  • Frequent change
  • High frequency communication

Do you ask someone who doesn’t feel like they fit in to do these things, is that going to have a good result? It is said that cooking should be done with heart, in fact, programming also needs to be completed with heart, a small negligence may cause serious consequences, the company insiders can not 100% guarantee, outsourcing team can guarantee? Finally, outsourcing will not save costs. In the short term, it will not reduce personnel costs. It may only reduce the risk of personnel turnover to a certain extent, but in the long term, it is a very cost-effective investment.

Code quality is enforced through penalties and rewards, right?

Some companies judge a person’s performance by the number of bugs. For example, programmers with many bugs will get a low performance score. Test engineers who detect more bugs have higher performance ratings. I always thought IT was a joke, but when I contacted more people, I found that many non-IT managers have such an idea. Although I did not implement IT under the strong opposition of my own team and myself, this idea is deeply rooted for many people. Can punishment and rewards improve the quality of your code? No software is perfect software, all software is a BUG, “the last time made people have bugs, let alone people make software?” Big IT enterprises with decades of experience, such as Microsoft, or emerging Internet giants like BAT, can’t guarantee that the software is bug-free even if there are many people and excellent people involved in the project. And there are two very serious problems with bug-based evaluation:

  • Do more and make more mistakes, then I do nothing or do less, then there are fewer bugs.
  • Find bugs, do not want to expose bugs, but secretly dispose of them.

This is clearly the opposite of AN IT technology that encourages innovation and sharing.

Establish a good code review system, ok?

In order to improve the code quality, team will define the code review system, such as “lack of working experience in * * year code must be checked by the competent”, “new recruits master code must review”, “development manager on a regular basis to the core code review” and so on, these provisions real also have certain effect, at least for the new colleague code specification, Improving the capabilities of inexperienced developers is useful, but because of the greater reliance on human scrutiny, it can be difficult to implement and difficult to adhere to. Before, our team insisted on such a method for a period of time. After obtaining the code, SVN would review the code of the concerned personnel. However, after a long time, it would basically return to the origin only by individuals or a few people. In fact, I have always had a question, is there really a pair programming company? Development engineer is a high-intensity job, the company wants programmers to write two people’s code, how can two people write a code. Maybe we need to find more advanced ways to replace purely artificial ones.

Hire better programmers

“One good programmer is more productive than 100 bad ones.” The similar conclusion is very popular in THE IT field, although different programmers are 100 times worse in ability is a bit of an exaggeration, but one good programmer is worth five bad programmers such things must often happen around us. I have always believed that program development is a very creative work, even if it is simple to add, delete, change and check, different business scenarios should be different implementation logic and technical means, we think in the head of the problem to spend much more energy than the implementation of the code. Good programmers are more productive, and the efficiency gap can be several times larger. And good programmers are really bug-less. Insert a simple operation, good programmers think of: how to ensure the consistency of the transaction, how to prevent continuous click to duplicate data, multiple tables can insert the parallel efficiency, and poor programmers will only consider the ideal external conditions, other problems are the problems of environment problems or operator. Are these, after the launch of the problem, the final is not a BUG? In the end, it’s up to developers to solve.

Pay attention to the training of internal personnel

To follow up, there are two ways to get good programmers: hire them or train them. As mentioned above, good code review is not a silver bullet, but it can be useful. In fact, code review can also be viewed as a form of internal cultivation. Each company in addition to the different business, we will not enter the discussion here, each company code has its own style, the style of a unified code, actually improving the quality of code is a good way, the company will have its own code of best practices, such as “alibaba code specification” circulating industry often “catch” 58 city database and so on. So taking the time to get your employees to agree on a code style can make a big difference in overall code quality. At the same time, many bugs are not only technical problems, but also lack of understanding of business. In addition to being more efficient, having a team that is stable over a long period of time and is able to create synergy also reduces the number of bugs.

Automated + manual methods to improve team capabilities

Code review has been mentioned many times before. Code review is obviously a way to improve code quality, but the review coverage can not play a full role. If there is an automated way to conduct code review, it should be a relatively perfect solution. At present, code management is managed through CVS tools, mostly Git or SVN. Automatic code review through code management tools is a very good way. When a user submits a code, a static code review tool (commonly used as Findbug, checkStyled, etc.) is forced to be used for review. If the code fails to pass the review, the code cannot be submitted. Although the code review tool is not very intelligent at the present stage, the basic code specification, null pointer prediction and other detection is relatively perfect, can largely avoid repeated manual review work. The review method of Move Fast is a manual review method implemented by many Internet companies. The commit and push of the code must be executed by two people, and the push operator must review the commit code, which can basically ensure the coverage of manual review and greatly help to improve the quality of the code. Artificial methods are mentioned here, so what should we pay attention to artificial methods? Static code scanning tools can help solve many basic code problems, but we should pay more attention to the problems that static code inspection tools cannot find:

  • Focus on problems in the loop body, call external services in the loop body, query databases in the loop body, and so on.
  • Code that involves multithreading or other asynchronous processing
  • The use of try catches, especially the code in the catch
  • Problems with static variable use

These are problems that are difficult to detect during testing, but can be easily exposed in production.

conclusion

Improving code quality is a very important issue for developers, especially development managers, but there is no silver bullet to achieve very good results. All the management systems, management models, etc., are actually not very helpful for creative work positions, “good people” is the best weapon to improve the quality of code, and an automated way to combine good people is probably the best way you want.


Wechat id: ITmifen