2. [Mandatory] Braces are used with if, else, for, do and while statements, even if the body contains only a single statement. Avoid using the following example:

    3. [Recommended] Use as less as possible, if-else statements could be replaced by:

    4. [Recommended] Do not use complicated statements in conditional statements (except for frequently used methods like getXxx/isXxx). Use boolean variables to store results of complicated statements temporarily will increase the code’s readability.

    Note: Logic within many statements are very complicated. Readers need to analyze the final results of the conditional expression to decide what statement will be executed in certain conditions.

    Positive example:

    5. [Recommended] Performance should be considered when loop statements are used. The following operations are better to be processed outside the loop statement, including object and variable declaration, database connection, try-catch statements.

    6. [Recommended] Size of input parameters should be checked, especially for batch operations.

    7. [For Reference] Input parameters should be checked in following scenarios:
      1) Low-frequency implemented methods.
      2) Overhead of parameter checking could be ignored in long-time execution methods, but if illegal parameters lead to exception, the loss outweighs the gain. Therefore, parameter checking is still recommended in long-time execution methods.
      3) Methods that needs extremely high stability or availability.
      4) Open API methods, including RPC/API/HTTP.
      5) Authority related methods.