1 / 16

CMPF 144

CMPF 144. Testing and Validating program. Programming errors. Debugging – is the process of finding and correcting errors in computer programs. Program debugging is another form of problem solving. 3 types of programming errors: Design errors Syntax errors Run-time errors. Design errors.

Download Presentation

CMPF 144

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CMPF 144 Testing and Validating program

  2. Programming errors • Debugging – is the process of finding and correcting errors in computer programs. • Program debugging is another form of problem solving. • 3 types of programming errors: • Design errors • Syntax errors • Run-time errors

  3. Design errors • Occurs during : • Analysis • Design • Implementation phases • Make mistake in translating an algorithm into program • Choose incorrect method of solution for the problem to be solved • Design erroneous data for the program. Difficult to detect Debugging process: review careful the problem analysis , algorithm design , test data

  4. Syntax errors/compilation errors • Violation of syntax rules • Syntax rules – define how the elements of a programming language must be written • Occur during the implementation phase –detected by compiler during compilation process • Compiler issues diagnostic message-warning message/error message

  5. continue • Warning message • Indicates a minor error that may lead to a problem during program execution. • Does not cause the termination of the compilation process. • May cause errors sometimes (if serious)… • It is a good practice to warning seriously and eliminate their causes in the program.

  6. continue • Error message • Will cause the compiler stop from compiling the program • It tell that nature of the errors and the location of errors in the program • Since compiler explicitly ‘inform” the errors, thus syntax errors is relatively easy

  7. Example: syntax error >>> while True print 'Hello world‘ File "<stdin>", line 1, in ? while True print 'Hello world' ^ SyntaxError: invalid syntax

  8. continue • The parser repeats the offending line and displays a little ‘arrow’ pointing at the earliest point in the line where the error was detected. • The error is caused by (or at least detected at) the token preceding the arrow: in the example, the error is detected at the keyword print since a colon (':') is missing before it. • File name and line number are printed so you know where to look in case the input came from a script.

  9. Example 2 >>> print a+b: SyntaxError: invalid syntax

  10. Run-times errors • Detected by computer while your program is being executed. • They are cause by program instructions that require the computer to do something illegal such as attempting to store inappropriate data or divide a number by 0. • When a run-time error is encountered, the computer produces an error diagnostic message and terminates the program execution.

  11. Example: run-time errors >>> print 1/0 Traceback (most recent call last): File "<pyshell#6>", line 1, in <module> print 1/0 ZeroDivisionError: integer division or modulo by zero

  12. Example 2 >>> list=[123,'abc'] >>> print list[1] abc >>> print list[2] Traceback (most recent call last): File "<stdin>", line 1, in <module> IndexError: list index out of range

  13. Testing and verification • Program verification- is the process of ensuring that a program meets user requirements • Technique that can be use to verify program is by using program testing. • What is program testing???? • program testing is the process of executing a program to demonstrate its correctness.

  14. continue • Used a set of data to test your program • Corrected output not necessarily means your program is logically correct.??? Why??? • Must test all the conditions (if any) , selection, looping all must be tested to look at the flow …logic or not…

  15. Data validation • In computer science data validation is the process of ensuring that a program operates on clean, correct and useful data. • It uses routines, often called “validation rules " or "check routines", that check for correctness, meaningfulness, and security of data that are input to the system. Visual Studio .NET 2003

  16. example • The simplest data validation verifies that the characters provided come from a valid set. • For example, telephone numbers should include the digits and possibly the characters +, -, (, and ) (plus, minus, and brackets). • A more sophisticated data validation routine would check to see the user had entered a valid country code, i.e., that the number of digits entered matched the convention for the country or area specified. Visual Studio .NET 2003

More Related