Java-controlled violations: resolving errors

Source: Internet
Author: User
Tags execution

From the oldest programming language, error control has always been a big problem that designers need to solve. Because it is difficult to design a perfect set of error control schemes, many languages simply ignore the problem and pass it on to the library designer. The main problem with most error-control scenarios is that they rely heavily on the programmer's alertness rather than on the language's own mandatory standards. If programmers are not vigilant-and if they are in a hurry, this is almost certainly happening-the error-control programs on which the program relies will fail.
"Unauthorized control" is built into the programming language, and sometimes even inside the operating system, by the error control scheme. The "violation" (Exception) here is a special object that "throws" or "throws" from the place where the error occurred. The violation is then designed to control the "unauthorized controller" capture of a particular type of error. When things get out of hand, there may be several unauthorized controllers that catch the corresponding offending object in parallel. As a standalone execution path is used, it does not interfere with our regular execution code. This makes the code easier to write because it doesn't have to be mandatory to check the code regularly. In addition to this, a "throw" violation is different from the error value returned from the function, or a flag set by the function. The effect of those error values or flags is to indicate an error state, which can be ignored. But the offence cannot be ignored, so it can certainly be disposed of somewhere. Finally, the use of violations can reliably recover from a bad environment. At this time generally do not need to exit, we can take some processing, restore the normal execution of the program. Obviously, the program is more reliable.
Java's illegal control mechanism differs from most programming languages. Because in Java, the offending control module is encapsulated from the very beginning, so it must be used! If you do not write some code to control the violation correctly, you will get a compile-time error message. This ensures the continuity of the program and makes error control easier.
Note that illegal control is not an object-oriented feature, although in an object-oriented programming language, an offence is usually represented by an object. Prior to the advent of object-oriented languages, unauthorized control was already in existence.

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.