Java Specification Control statements

Source: Internet
Author: User

1, in a switch inside, must have a default in the end, even if there is no logic.

2, the expression of abnormal branches, less use if else, this can be changed to:

if (condition) {

Return

}

If you have to use if else to avoid more than three layers. Otherwise maintenance is difficult. Can be replaced with either a statement or a state pattern.

3. Do not execute complex statements in conditional judgments.

4, in the loop body to consider the performance of the statement, define variables, objects, get database connections, exception capture, as far as possible on the outside of the loop.

5, the following conditions need to verify the parameters:

1) The method of low frequency call;

2) The method of executing time expenditure is very high;

3) methods that require very high stability and availability;

4) Open interface provided externally;

5) Sensitive access entry.

6, the following conditions can not verify the parameters:

1) A method that is most likely to be called by a loop;

2) Low-level call frequency relatively high method

3) A method that declares itself to be called by private;

Java Specification Control statements

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.