JavaScript code review (review)

Source: Internet
Author: User

I. Summary section

A) Does the code conform to the requirements and specifications?

b) is the code design considered comprehensive?

c) How readable is the code?

d) is the code easy to maintain?

e) have each line of code been executed and checked?

Second, the design specification part

A) is the design compliant with known patterns or patterns commonly used in projects?

b) Are there hard codes or strings/numbers that exist? (separated from the configuration, only need to change the configuration file without changing the code)

c) is the code dependent on a platform and does it affect future porting? (Browser compatibility)

D) Does the new code show a situation where similar functionality can be invoked without being called? (Repeat code)

e) is there any useless code to erase? (Save old Code with Code control tool)

Third, Code specification section

a) Indent

Four spaces

b) Line width

100 characters

c) Brackets

In complex conditional expressions, precedence should be clearly expressed in parentheses

d) Curly Braces

if (true) {

Some ();

}else{

Some ();

}

e) Branch

Multiple variables multi-row definition

f) naming

String Svar

Digital Type Ivar

Boolean type Bvar

Array Avar

Object Ovar

g) Underline

Used in private variables or local variables. Example: _ivar

h) Uppercase and lowercase

class, variable noun Member

function verb/dynamic-bin combination GetMember

i) Notes

1. Don't explain how the program works (how)

2. What the program does (what) and why it should be interpreted (why)

3. Areas requiring special attention

4. Do not use Chinese and special characters

5. Double slash after adding a space after writing the content

6. The meaning of complex variables must indicate what is the variable

7. The method must indicate

@todo: Things to do

@author: Author (required)

@review: Issues found when recording a review

@bug: Log issues that have occurred

@param: Instructions for entering the parameter (required)

@return: Instructions for out-of-reference (required)

@exception: Type of Exception thrown

@deprecated: It is not recommended to use this method

Example:

/* * * function function Brief * * Specific description of some details * * @param    {string}     Address * @param    {array}   COM         commodity array * @param    {string}  Pay_status  payment method * @returns  void * * @date     20170707 * @author   **

8. Simple and clear, meaning accurate

9. Uniform annotation Form

10. Notes Synchronize updates with code

11. Delete Useless comments before publishing

j) function

1. Do only one thing and do it well

2. Verify the correctness of the parameters

3. Assert that the method may fail to write a corresponding null judgment, and then execute the next code

Iv. Specific Code sections

A) Have you dealt with the error?

b) are the parameters passed with or without errors?

c) How is the boundary condition handled? Is there a possible cycle of loops?

D) Is there any use of assertions to ensure that the conditions we consider to be immutable are really met?

e) Are there elements in the data structure that are not used?

V. Effectiveness

A) How effective is the code? What is the worst case scenario?

b) is the code especially a part of the loop that is obviously optimized?

c) Does the call to the system and the network time out and how to handle it?

Six, readability

A) How readable is the code?

b) Is there a sufficient amount of comments?

Seven, testability

A) Do you need or create a new unit test?

JavaScript code review (review)

Related Article

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.