How to write robust Java code

Source: Internet
Author: User

Recently in the company to write code, write code found a lot of bugs, in order to achieve a function, the code changed and changed, affecting the efficiency of work orders, but also affect individual performance, so from the Internet to find some articles about writing robust code to look at, plus some of their own experience summary.

The so-called robust code refers to: robustness, also known as robustness , refers to the software to the requirements of the input outside the processing capacity of the situation.

The so-called robust system refers to the input beyond the requirements of the specification can be judged that the input does not meet the requirements of the specification, and can have a reasonable way of processing.

In addition, robustness is sometimes a place where fault tolerance , portability, and correctness intersect. For example, a software can infer the correct input from the wrong input, which is a fault-tolerant metric, but it can also be considered robust. a software can be correctly run in different environments, the software portability is considered high, can also be called, the software is robust under different platforms. a software can detect its own internal design or coding errors, and get the correct execution results, this is the correctness of software standards, but also can be said that the software has internal protection mechanism, is the module-level robust. software robustness is a relatively vague concept, but it is a very important external measurement standard of software. The robustness of software design directly reflects the level of analysis design and coding personnel. The so-called Master Writing program is not easy to die. "Baidu Encyclopedia"encapsulation and information hiding are the basic principles leading to robust class and component design1. Try to have Try--catch statement block in the method2, for the For loop for (int i=o;i<list.size (); i++) is obviously not as robust as for (int i=o;list!=null&&i<list.size (); i++). [to be continued]

How to write robust Java code

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.