Day 11 - Types of Programming Errors
Day 11: Types of Programming Errors
Learning Objectives
- CRD-2.I: Describe how a code segment or program functions.
Essential Questions
- What are the different types of errors in programming?
- How do different errors affect program execution?
Materials Needed
- Presentation slides on error types
- Sample code with various errors
- Error identification worksheet
- Sticky notes for exit tickets
Vocabulary
- Syntax error
- Logic error
- Run-time error
- Overflow error
- Compile-time error
- Exception
- Bug
- Debug
Procedure (50 minutes)
Opening (8 minutes)
-
Review and Week 3 Introduction (3 minutes)
- Review key concepts from Weeks 1-2
- Introduce Week 3 focus on errors and project work
-
Warm-up Activity (5 minutes)
- Show students a program with an obvious error
- Ask them to identify what's wrong and how to fix it
- Discuss different approaches to finding the error
Main Activities (32 minutes)
-
Lecture: Different Types of Errors (12 minutes)
- Explain syntax errors:
- Incorrect grammar/structure of code
- Usually caught by compiler/interpreter
- Examples: missing semicolons, mismatched parentheses
- Explain logic errors:
- Code runs but produces incorrect results
- Program doesn't do what was intended
- Examples: incorrect algorithm, wrong formula
- Explain run-time errors:
- Errors that occur during program execution
- Program crashes or terminates unexpectedly
- Examples: division by zero, accessing invalid memory
- Explain overflow errors:
- Values exceed the allowed range
- Examples: integer overflow, stack overflow
- Explain syntax errors:
-
Demo: Examples of Each Error Type (10 minutes)
- Show examples of each error type in code
- Demonstrate how each error manifests:
- Error messages for syntax errors
- Incorrect output for logic errors
- Program crashes for run-time errors
- Unexpected behavior for overflow errors
- Explain the consequences of each error type
-
Lab: Identify Error Types (10 minutes)
- Provide students with several code segments containing errors
- For each segment, students must:
- Identify the type of error
- Explain how they recognized it
- Describe the impact on program execution
- Suggest a fix for the error
- Review answers as a class
Closing (10 minutes)
-
Error Identification Worksheet (7 minutes)
- Students complete a worksheet with various code segments
- For each segment, they identify the error type and explain their reasoning
- Include examples of all error types covered
-
Preview Next Lesson (3 minutes)
- Explain that next class will focus on error correction techniques
- Ask students to think about strategies they use to find and fix errors
Assessment
- Formative: Participation in error identification lab
- Error Identification Worksheet: Accuracy in identifying error types
Differentiation
For Advanced Students
- Provide more subtle and complex errors to identify
- Ask them to create examples of different error types
- Explore more specialized error types (e.g., boundary errors, concurrency issues)
For Struggling Students
- Provide more obvious examples of each error type
- Offer a reference sheet with error characteristics
- Allow collaborative work on error identification
Homework/Extension
- Create a "cheat sheet" for identifying different error types
- Find and document an error in a previous programming project
- Research a famous software bug and its consequences
Teacher Notes
- Emphasize that errors are a normal part of programming, not failures
- Connect error types to the development process (when each might be discovered)
- Point out that the AP exam may ask about identifying error types
- Preview that error correction will build on this knowledge in the next lesson