How code review (Code Review)

The importance of code review

  • Code review is familiar with the software architecture, a good way to understand the logic of the software business. Learning code is the entry point of need, a million lines of code on the system, from where started? Only one module a module, a component of a component to be familiar with and master. Achieve a larger feature, you should not be the only developers, system architects design output from the system, and then to the component-level design of each team Leader output technology, when to begin to implement, the function will be divided there are different developers to achieve synergies for different modules. This is an opportunity to learn, do not just limit ourselves to this part, in order to understand this great function, even other functions and this has been achieved related functions, you also need to focus on the work of others. Purposeful look and aimless browsing effect of the code is not the same, you have an understanding of the new features, before reviewing the code, you think how to write code, and others where you do not want the same old features and new how features affect each other, and so, at her heart problem, you learn faster, remember more deeply.
  • Code review is a good way to improve your own. Provided that the team in the presence of experienced developers. That is Daniel, do not miss your chance to let him see the code, do not be afraid that he would write the code for you to pick out a lot of questions, some people say you write the code as her own children, can not see people say not the slightest word Do not stubborn, to inner peace, an objective to look at the code you write, identify and solve problems in order to improve yourself. Do not miss the opportunity to review Daniel code, look at the big cattle is how to write code, you can select the essence.
  • Code review is needed skill. Online post that senior work experience or not and are not necessarily linked programmer, you are 5 years of work experience or an experience with five years, which requires you to deliberate practice, beginning reveiew code when you may not be used, also may be very painful, the code of a screen do not know how to face under the eye. But there is a saying, if you feel very comfortable inside, you're running in place. Feel the pain that you are climbing, deliberately to contact your brain it, you see today, a code may use for an hour and found no problems, but after a month or even three months, you will be able to look at find code defects, Congratulations, your skill deepened.

Code Review List

General items

  • Code to work it? It has no function as intended, the logic is correct and so on.
  • All code is easy to understand?
  • Programming code meets specifications you follow it? This usually includes a location braces, variable names and function names, length of the line, indent, forms and annotations.
  • If there is excess or duplicate code?
  • Whether the code is modular as possible?
  • Whether there may be replaced by global variables?
  • Is there a code is commented out?
  • Cycle length and whether a proper termination condition?
  • Is there a library function can be replaced by the code?
  • Is there a log or debug code that can be deleted?

Safety

  • Whether all the input data have been checked (detected the correct type, length, format, and range) and are encoded?
  • Where the use of third-party tools, if an error is returned to be captured?
  • Whether the value of the output was examined and coding?
  • Are Invalid parameter value can handle?

File

  • Are there comments, and describes the intent of the code?
  • All functions have a comment it?
  • Unconventional behavior and boundary treatment if the situation described?
  • Whether to use third-party libraries and functions for documentation?
  • Data structures and units of measure whether or not the explanation?
  • Is there a code is not complete? If so, is not it should be removed or marked such as 'TODO' with the appropriate tag?

test

  • Whether the code can be tested? For example, do not add too much or hidden dependencies can not initialize an object, you can use methods of testing framework.
  • Whether there is a test, whether they be understood? For example, at least you satisfied with the code coverage (code coverage).
  • Unit testing whether the real test of whether the code can complete its intended function?
  • Check that the "out of bounds" error array?
  • Are there existing API can be replaced by test code?

You also need to add specific language may cause the wrong question to the list.

Optimize your inventory

Use the list as your starting point, for specific use cases, you need to be optimized. A relatively stick way is to get your team to record those problems in the code review process found in the interim, with these data, you'll be able to determine the error often made by your team, then you can tailor a review list . Make sure you delete those errors have not seen before. (You can also keep the probability of occurrence of those small but critical projects, such as security-related issues).

Recognized and kept up to date

And your team to share this list and let them identify the contents of your list is a good idea. Similarly, to regularly check your list to make sure that each entry is still meaningful.

有了一个好的清单,除了可以提高你在代码审查过程中发现的缺陷个数,还可以帮助团队成员更好更快的进行代码审查。

Guess you like

Origin www.cnblogs.com/kuangliu/p/10942273.html
Recommended