6.8. Debugging Caesar Cipher¶
Time Estimate: 45 minutes
6.8.1. Introduction and Goals¶
In this lesson, we will learn more about the types of errors you might get in a program, including tips for identifying, fixing, and preventing them. First, watch the video below. After watching the video, try to identify and correct the errors in the Caesar Cipher app and then answer the questions about debugging. When watching the video, look for these important terms and concepts:
- Bug - In computer programming, a bug is an error or defect that prevents the app from working the way it is supposed to.
- Debugging - The process of removing errors from computer hardware or software.
- Logic Error - A mistake in the algorithm or program that causes it to behave incorrectly or unexpectedly. Also referred to as a semantic error.
- Syntax Error - A mistake in the program where the rules of the programming language are not followed.
- identify and correct errors in a program
- explain the difference between syntax errors and semantic errors
- use target vocabulary, such as syntax error, semantic error, and run-time error while fixing errors in an app, with the support of concept definitions and vocabulary notes from this lesson
6.8.2. Learning Activities¶
The activity for this lesson is to debug a version of the Caesar cipher app. There are at least five errors in this version of the app. See if you can find and correct them all! To get started, open App Inventor with the Caesar Cipher Buggy template.
Here are some hints and suggestions.
- If you see a run-time error message, read it carefully - it's trying to tell you where the bug is. A run-time error is a mistake in the program that occurs during the execution of a program. Programming languages, such as MIT App Inventor, define their own run-time errors. For example, if the run-time error complains about exceeding the length of the text, then the loop going through the text letter by letter did not stop at the end of the text.
- The bugs can be in both the encryption and decryption steps. So make sure you test the app thoroughly, with appropriate inputs. When you are testing this app, only type in lowercase letters in the plaintext textbox to encrypt, and only type in uppercase letters in the Ciphertext textbox to decrypt.
- You are may see more problems if you encrypt longer rather than shorter messages.
- If you are having trouble locating a problem, use a Notifier or use Label1 to display intermediate values of local or global variables.
- You may also compare this code to your finished Caesar Cipher app from the previous lesson.
- Use App Inventor's Do It tool to evaluate expressions and intermediate values. Here's a short video on how to use Do It.
In this lesson, you learned how to:
Here is a table of some of the technical terms discussed in this lesson. Hover over the terms to review the definitions.