Code Review Results

Source: Internet
Author: User

Explanation: Because of this special reason, I am working with a student in Korea and a classmate of class six to program together.

General

    • (N) Does the code work? Does It perform it intended function, the logic is correct etc.

The code of the two-bit pairing partner can only be implemented as part of the requirements feature:

  • Z Students currently realize the function is: can only generate 10000 of the number of, no go to re-judge, the subtraction of the whole problem.

The classmate did not fulfill the requirements of the function: fractional participation in the operation, the generated part of the topic must contain parentheses, the resulting problem is not duplicated, with command line control parameters, parameter error prompt, given the question and answer file to check, support more than 10000 of the amount of data.

The classmate realizes the wrong function has: The range scope contains the value of the-R parameter.

  • The current functions of the students are: the answer check (without parentheses) of the simple subtraction item in the range of 0~10 integers typed from the keyboard.

This classmate does not realize the demand function is more, basically did not complete the function.

    • (Y) is all the code easily understood?

Because their code implementation function is weak, both students are written in C + +, all only the main function: (. The code structure is relatively simple and clear.

    • (N) (Does it conform to your agreed coding conventions? These would usually cover location of braces, variable and function names, line length, indentations, formatting, and comme Nts.

Although the number of lines of code is small, but the name of the code variable z classmate I am not very accustomed to, his name is like this:

int 0; int N; int R; int i=0; int NINT; int number_num; int op_num; int number;

There are no explanatory notes and explanations of their meanings next to each variable: (.

The name of the code variable (although only two) is short, slightly different from the variable naming habits I used to.

In other words, Z Classmate's indentation style is poor, because while loop and so on is equal to, part of the code is as follows:

 while (an<1+rand ()%3= op_num+1;  while (i<op_num) {    number =1+rand ()%R;    cout<<1+rand ()%R;     = rand ()%4;

Y students are relatively good in the style of indentation, at least it looks more comfortable.

Z classmates have some comments at the beginning of the loop, but Y classmates have no comments.

    • (N) is there any redundant or duplicate code?

There is no redundant code in the code of classmate Z and classmate Y. (because it is quite simple to write)

    • (N) is the code as modular as possible?

Both students are written in C + +, and only the main function is used. And there is no modular idea ...

    • (N) Can any global variables is replaced?

The reason for choosing n is ... My pairing partners do not use global variables.

    • (N) Is there any commented out code?

Neither of the students seems to have experienced long code development time, so there is no outdated code with debugging code.

    • (Y) Do loops has a set length and correct termination conditions?

Yes. And no infinite loops are seen from the code.

    • Can any of the code being replaced with library functions?

Z Classmate's code and Y's code implementation of the function is relatively simple, can achieve the use of library functions are using the library function.

    • Can any logging or debugging code be removed?

The code of the two classmates is not recorded or used to debug the legacy code.

Security

    • Is all data inputs checked (for the correct type, length, format, and range) and encoded?

Z classmate only the input of the-n parameter >10000 when the error treatment, in other cases, such as n is negative, r is negative, and so there is no error check. (see here, in fact, my code does not have this aspect of error handling, just the input position of the parameter error will be prompted, but did not consider the case of N and R is negative, it is my blunder: (. )

Y students in their 0~10 of the individual expression of the calculation program of the input number of the range (0~10) was judged and limited, but did not make any error processing.

    • Where Third-party Utilities is used, is returning errors being caught?

Students do not use third-party tools; The program does not actively throw any controllable exceptions, and some errors are processed using the form of printouts.

Y classmate does not have any output error description.

    • is output values checked and encoded?

Both students have checked the output of the expression by whether the divisor is 0.

But neither of the two classmates checked whether the result of subtraction was negative. The rest is not implemented because of the functionality, so there is no check to make it.

    • is invalid parameter values handled?

Both of the students ' Default user input is legal. Therefore, the invalid parameters are not processed.

Documentation

    • Do comments exist and describe the intent of the code?

Only Z classmates have a short comment similar to overview, but Y classmates do not have any descriptive comments.

    • Is all functions commented?

Both students have only main function, Z classmates are all have comments, Y classmate no comment.

    • Is any unusual behavior or edge-case handling described?

Neither of the two classmates had the edge situation handled (although the code was processed) into the comment.

    • is the use and function of Third-party libraries documented?

No... Are not used ...

    • Is data structures and units of measurement explained?

If the array is a data structure, z students use the data structure of the array and write a comment to explain its role.

    • Is there any incomplete code? If So, should it is removed or flagged with a suitable marker like ' TODO '?

Both students have a lot of code that needs to be written to complete the requirements function.

Testing

    • Is the code testable? i.e. don ' t add too many or hide dependencies, unable to initialize objects, test frameworks can use methods etc.

Two classmates only main function, basically cannot construct test sample.

    • Do tests exist and is they comprehensive? i.e. have at least your agreed on code coverage.

Two classmates did not finish, so there is no test.

    • Do unit tests actually test, the code is performing the intended functionality?

No test code.

    • is arrays checked for ' out-of-bound ' errors?

two students did not detect the cross-border of the array.

    • Could any test code being replaced with the use of an existing API?

No...

The partner code for this pair of programming is slightly less capable, and we've been discussing it (already with Mr. Luo) I'm going to use pairing programming mode with new people: After I have detailed module partitioning for each feature, I watch them complete some small modules and some unit tests as pilots. Then I write some code and detailed comments so that they understand and digest themselves every day. I hope they can learn something in the process of pairing with me: D.

Code Review Results

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.