Agile development practice series
From ant Financial’s perspective, the self-developed middleware, database, r&d platform and other financial technologies lead the technological trend of enterprise digitization. Among them, ant R&D efficiency as the representative, spawned a lot of enabling industry methodology and engineering practice, based on the insight into the field of R&D efficiency, specially launched agile development practice series of articles, today will start from the Code level, Code Review this basic and important link will be analyzed.
Author’s brief introduction
The rain is known
Ant Financial product expert
Li Sushi, flower name Yu Zhi, product expert of r&d Efficiency Department of Ant Financial. Years of configuration management work, rich code services, r & D mode of practice experience.
01
preface
Code Review is also sometimes called Code Review. As defined by Wikipedia, Code Review is a systematic examination (sometimes referred to as peer Review) of computer source Code. Its purpose is to find the early development overlooked errors, so as to improve the overall quality of software. Reviews can take many forms, such as pair programming, informal walkthroughs, formal inspections, etc. In more than 12,000 software development projects analyzed by Capers Jones, potential defect detection rates for those using formal code reviews range from 60 to 65 percent, to less than 50 percent for informal code reviews. For most tests, the potential defect detection rate is around 30%.
02
What can a good Code Review do?
Finding problems: Finding problems through reviews to improve Code quality is the most common understanding, and the broadest understanding of the benefits of Code Review.
Knowledge sharing: Code review is a means to transfer knowledge to other students who are not familiar with the code to know the author’s intentions and ideas. Although the reviewer may not be as knowledgeable as the author, he will be familiar with the design and architecture and act as a backup.
Help you Grow: Code reviews are purely social and provide an opportunity for the team to nurture developers.
Generally speaking, the team began to do Code Review, focus on finding problems, as the problem of habit gradually reduce and gradually develop, communication and knowledge sharing will be a key, when there are a large number of new people to join, to find the problem will become the key again, through such a cycle process improve the Code quality, knowledge sharing, to help developers to grow.
03
How to do a good Code Review?
Code Review is closely related to human factors, and its effective operation is closely related to team status, technical belief and TL appeal. Therefore, in Code Review, it is necessary to cultivate awareness, methods and mentality and keep good Code Review habits, which will improve a lot in all aspects. The following three aspects will be carried out:
consciousness
The purpose of Code Review is to improve the quality of the Code and promote knowledge sharing within the team to help more people understand the system better. Therefore, we should make clear our goals and principles in consciousness:
-
Discover the correctness of code.
-
Not only review the code, but also share and learn, improve the overall level of the team, improve the team’s ability to maintain the code.
-
Finish code review efficiently and quickly, not to meet the need.
methods
1. Clear review content: reviewers should check the rationality of the design and the error of the business logic, and check the readability of the code:
-
Architecture and code design
-
Code style.
2. Improve the quality and efficiency of reviews
-
Control the amount of code per review Smartbear at Cisco code review studies show that for optimal efficiency, developers should review fewer than 200-400 lines of code (LOC) at a time. Beyond this amount, the ability to search for defects decreases. At this rate, you can find 70-90% of defects. In other words, if there are 10 defects, you can find 7 to 9 of them.
-
The optimal amount of code review varies depending on the development platform and language, but limiting the number of reviews per review is necessary because the process is a highly brain-intensive activity. Over a long period of time, the code in the eyes of the reviewer is just letters, without any logical connection, naturally will not have too much output.
-
Code reviews take time, but quick reviews are not always good. Smartbear optimizes results when Cisco code reviews show check rates below “300-500 LOC/ hour.” As shown in the figure below, server-side review speeds of more than 400 LOC per hour decrease efficiency, while review speeds of more than 500 lines of code decrease significantly.
-
Verify that problems are actually fixed Fixing problems found by reviewing code is a smooth process, and we need to have a good way to track down problems found during review and ensure that problems are actually fixed.
-
Multiple people review your code as much as possible. Different people think differently and have different opinions, so that different people can review your code from all aspects. Basically, no more than three people, this is the maximum size that can be discussed in a group.
3. Summary and optimization: Some teams fail to stick to Code Review activities or gradually become formalized. One of the main reasons is the lack of regular Review and summary in the process, so they do not know how to effectively promote and help the team to operate better. Establish quantifiable goals for code reviews to help improve the process.
4. Choose the right tools: “To do a good job, you must sharpen your tools.” Strict procedures can stifle creativity, but loose procedures mean no one knows if reviews are effective or even happening. And the social effects of personal criticism can damage morale. Industry experience has proven that lightweight code reviews are efficient.
State of mind
Both the author and the reviewer need to have a positive, positive attitude. The author needs to be open to suggestions from others because they are intended to make you do better. The reviewer also needs to be positive about the author, because that’s the guy you’re in the trenches with. The team needs to maintain an attitude that finding problems means that the coders and reviewers working as a team to improve the quality of the product have succeeded. Rather than “the developer created a defect, and the reviewer is responsible for finding it.”
04
What does Ant Financial do?
Ant Financial Code service platform creates a suitable CR platform for students who use Gitflow + merge request to conduct Code Review, so as to realize the upgrade of the overall Code service. The operation of merge request is inseparable from Code Review.
Merge requests are the foundation of code collaboration. As the name suggests: this is a merge request, merging from one branch to another. Merge requests may be new requirements, optimizations, defect fixes, and so on. Typical processes include: How do I submit a merge request? How are merge requests reviewed to determine acceptance? Who handles mergers? The notification mechanism after the merger. By merging requests, you can:
-
Compare the changes between two branches
-
View and comment on code changes online, and document problem status
-
Review Settings support a variety of review requirements, such as multi-person review
-
Merge request Settings control merge access
-
Displays a list of merge conflicts
-
Squash merge makes the commit history clearer
-
Merge request versions, based on each push, can select and compare the versions of these merge request differences
At the same time, the access Settings for merge requests can be multiple. For example, developers on the team need to submit code:
-
Create a new branch and modify the commit code
-
Create a merge request to commit the changes to the code
-
The rest of the team discusses feedback in the review record of the merge request
-
The submitter received an email notification, and revised the solution according to the review comments
-
After these checks are passed, the merger is approved
05
conclusion
The above has introduced some Code Review practices. The applicability of these methods needs to be verified in their own practice and adjusted according to the actual situation, so as to achieve the goal of Code Review. If you have any questions or experience exchange, please reply to us through the official account. Let’s Review together!
Long press to identify the QR code to follow us
P.S.
Ant Financial’s R&D performance team is in the process of recruitment, and many positions such as solution architect, technical operation, data R&D experts, technical experts, technical support experts, product experts, test platform senior development engineer, code analysis technical experts and so on are still open. Together, let us go to war in DevMind/enterprise/DevServices three, boost the internal and external partners to improve r&d efficiency 🚀 🚀 🚀
If you are interested in any position, please leave your contact information or send your resume to [email protected]
Click here for more job details