User and system errors Correct response to exceptions and errors Well designed programs should respond : A program probably cannot produce useful, correct results if it is operated incorrectly (garbage in, garbage out). It should, however, respond appropriately . An appropriate response depends somewhat on the application. In most desktop computer applications the appropriate response is to display a polite message to the user stating what the problem is. Here is an example. Suppose the user of a word processor tries to save a document file on a disk in which there is not enough space. The response from the program could be any of the following (arranged from most appropriate to least appropriate). There is not enough free space on the selected disk to save this document. If you want to continue you should delete some files on this disk or select a different disk Out of space on drive C: Disk full! Sorry! ERROR Java.lang.NullPointerException at MyProgram.writeFile() on line 132 [followed by lines of meaningless debugging information] The last of these responses probably constitutes a crash . This is probably the result of the programmer doing nothing at all to deal with the incorrect operation, and the consequences being detected by something else. The notion of a crash is discussed in more detail below. Sometimes computer programs are subject to system errors. Such errors result, for example, from unplugging a cable to switching the power off without warning. In rare cases computer equipment has been known to catch fire. It is impossible to respond in any useful way to most system errors. If the power is switched off it is impossible to respond at all. However, the system should respond safely . By this it is meant that the amount of damage caused by the failure is minimized. For example, most word processors save the users work to disk automatically at regular intervals. Even if the power is switched off, the user will lose only a limited amount of work. Back to top 
RITSEC - Global Campus Copyright ?1999 RITSEC- Middlesex University. All rights reserved. webmaster@globalcampus.com.eg |