Activity 6: Debugging
Teaching students to identify and fix bugs in code through hands-on activities.
Description
This activity is designed to educate students on debugging and the various manifestations of bugs in code. The lesson will encompass an activity that assists students in identifying the presence of a bug, methods for resolving it, and distinguishing between syntax errors and logic errors. Syntax errors occur due to grammatical or indentation mistakes in the code, which prevent the program from running correctly. These errors are akin to misspellings or improper punctuation in written language. On the other hand, logic errors arise when the lines of code, while syntactically correct, do not produce the intended outcome. These errors are caused by flawed logic that the computer cannot interpret as intended, leading to incorrect or unexpected results. The activity will use instructions to represent syntax and logic errors that the student will need to identify. It is crucial to highlight what each example represents to ensure a clear understanding of these concepts.
Materials Required
- Debugging Video: Bugs!
- Debugging Scenarios
- Pencil
- Paper
Steps to Conduct the Activity
Step 1: Printing out Debugging Sheets
- Print out debugging sheet before activity starts or during debugging video if you are running activity with someone else
DEBUGGING SHEET: Debugging Sheet
DEBUGGING ANSWER SHEET: Answer Sheet
Step 2: Watching Debugging Video
- Show students Debugging video Bugs!
- After the video is done ask them about what they think bugs in coding will look like
- Also ask them if they think bugs can show up in different ways or only one.
- Following this, it is important to emphasize to the students the types of errors they may encounter while learning to code. Syntax errors occur due to grammatical or indentation mistakes in the code, which prevent the program from running correctly. These errors are akin to misspellings or improper punctuation in written language. On the other hand, logic errors arise when the lines of code, while syntactically correct, do not produce the intended outcome. These errors are caused by flawed logic that the computer cannot interpret as intended, leading to incorrect or unexpected results.
Step 1: Identifying Bugs
- Hand out the Sheets of paper with the identifying bugs side first
- With the written examples in the first part of the sheet explain to students that instructions that do not make sense or are grammatically incorrect can be identified as bugs
Step 2: Categorizing Bugs
- The second part of the sheet has all bugs, direct the students to identify if the instruction be would syntax errors or logic errors
Step 3: Practice
- Have students create instructions that contain Bugs , no Bugs, syntax errors, and logic errors.
- This exercise will improve their understanding of how to identify bugs and the different types they might encounter.
Reflection
- Explain the similarity between actual code and the activity, emphasizing how debugging requires the skills practiced in the activity.
- Ask students if they found the activity challenging and what new concepts they learned.
- Inquire which was harder: identifying bugs or categorizing them.
Summary
This activity introduces students to the basics of debugging. It highlights common errors in code and methods for addressing them. Engagement in these activities can better prepare students for coding by providing a solid understanding of how to handle errors.