Learners will be able to:
- Know what different types of programming errors can occur.
- Be able to recognise these errors.
- Apply skills to fix the error.
- Combine this as part of the testing approach.
In this lesson you will learn about errors or bugs that occur in programming. In particular you are looking to identify syntax and logic errors. Through testing with valid, invalid and extreme data, you can identify the errors and then begin to correct them.
Part 1: Testing Errors:
Part 2: Types of Errors:
Part 1: Testing Errors:
- Testing is carried out to identify errors that may cause issues or problems when the program executes. This stops the program from doing what it is supposed to do.
- Think of all the places where there are tests can you come up with a test which begins with every letter of the alphabet?
- A - Acid Test,
- B - Baseline assessment KS3
- C -
Part 2: Types of Errors:
- Runtime errors are errors which will cause the program or computer to crash even if there appears to be nothing wrong with the program code. Running out of memory will often cause a runtime error. This could be because instructions have been written in the wrong order.
- Syntax errors are mistakes in the way that the code is written. Translators can only execute a program if it is syntactically correct. Common syntax errors include spelling mistakes, incorrect use of punctuation and the use of capital letters.
- Logic errors in computer programming, a logic error is a bug in a program that causes it to operate incorrectly, but not to terminate or crash. A logic error produces unintended or undesired output or other behaviour, although it may not immediately be recognised.
Part 3: Syntax Errors:
“Hello have a great day”
Part 4: Have a go now!:
- A syntax error in coding is an error caused by not meeting the required method or way of writing the language. Can you think of some syntax errors that are commonly found in the English language?, for example, not using a capital letter at the start of a sentence.
- Look at the program below, what is the syntax error and why?
“Hello have a great day”
Part 4: Have a go now!:
- Look at the code below which adds together two numbers. Unfortunately it contains four syntax errors, can you do a Grace Hooper? Find the errors and and solve them.
- Now create you own syntax error and challenge another students to find and solve it.
Part 5: Logic Errors:
Hourly Rate = 5.50
Pay = 10 x 6.50
print pay
- A logic error occurs when an incorrect answer or value is returned or calculated. This may not cause the program to stop. Consider the example below,
Hourly Rate = 5.50
Pay = 10 x 6.50
print pay
Part 6: Have a go, you want some?!
- Look at the code below, it does not work, it contains a logic error, can you do a Grace Hopper and find the error and sort it?
- Discuss what was the error an why did it occur?
Putting it all together, well not really:
- Look at the code below, it is full of errors, oh dear, I am not happy! Do a Grace Hopper and find the errors and sort them out?
- The correct answer is 55.
R.P.S.L.S.
The program below is the classic game of RPSLS, never heard of it? Check out the video below.
The program below is the classic game of RPSLS, never heard of it? Check out the video below.
Sabotage
Look at the code below for the game, you will sabotage it by creating an error, then get another student to see if they can correct it.
|
|