Day 15 - Program Development with Functions
Day 15: Program Development with Functions
Learning Objectives
- AAP-3.A: For procedure calls: Write statements to call procedures.
- AAP-3.B: Explain how the use of procedural abstraction manages complexity in a program.
- AAP-3.C: Develop procedural abstractions to manage complexity in a program by writing procedures.
- AAP-3.D: Select appropriate libraries or existing code segments to use in creating new programs.
Essential Questions
- How do we design modular programs using functions?
- How do functions work together to create complete programs?
Materials Needed
- Presentation slides on modular program design
- Programming environment
- Program design templates
- Mini-project requirements
- Exit ticket templates
Vocabulary
- Modular design
- Decomposition
- Top-down design
- Bottom-up design
- Function hierarchy
- Interface
- Implementation
- Abstraction
- Encapsulation
Procedure (50 minutes)
Opening (8 minutes)
-
Review and Connection (3 minutes)
- Review libraries and APIs from previous lesson
- Connect to today's focus on developing complete programs with functions
-
Warm-up Activity (5 minutes)
- Present a complex programming task
- Ask students to brainstorm how they might break it down into smaller functions
- Discuss different approaches to decomposing the problem
Main Activities (32 minutes)
-
Lecture: Modular Program Design (12 minutes)
- Explain the concept of modular program design:
- Breaking down complex problems into smaller, manageable parts
- Creating functions for each part
- Combining functions to create a complete solution
- Discuss approaches to program decomposition:
- Top-down design: start with the big picture, break into smaller parts
- Bottom-up design: build small components first, then combine
- Explain function hierarchy and relationships:
- Main functions and helper functions
- Function dependencies
- Function composition
- Discuss best practices for modular design:
- Appropriate function size and scope
- Clear interfaces between functions
- Minimizing dependencies
- Reusing functions when possible
- Explain how modular design supports:
- Collaboration
- Testing
- Maintenance
- Code reuse
- Explain the concept of modular program design:
-
Demo: Breaking Down Problems into Functions (8 minutes)
- Walk through the process of designing a modular program:
- Analyzing the problem requirements
- Identifying major components
- Defining function interfaces
- Implementing individual functions
- Combining functions into a complete program
- Show examples of well-designed modular programs
- Demonstrate how functions interact through parameters and return values
- Highlight the benefits of the modular approach
- Walk through the process of designing a modular program:
-
Hands-on: Collaborative Program Development (12 minutes)
- Students work in pairs or small groups
- Assign each group a mini-project that requires multiple functions
- Guide students through the development process:
- Planning the program structure
- Identifying necessary functions
- Defining function interfaces
- Dividing implementation responsibilities
- Integrating functions into a complete program
- Encourage students to document their functions
- Circulate to provide guidance and feedback
Closing (10 minutes)
-
Activity: Mini-project Using Functions (5 minutes)
- Groups continue working on their mini-projects
- Focus on integrating functions and testing the complete program
- Share and discuss different approaches to modular design
- Highlight successful strategies and common challenges
-
Exit Ticket and Preview (5 minutes)
- Students submit their modular programs with documentation
- Preview that next class will focus on lists/arrays as data structures
Assessment
- Formative: Quality of program decomposition and function design
- Mini-Project: Effectiveness of modular design and function integration
Differentiation
For Advanced Students
- Assign more complex mini-projects requiring sophisticated decomposition
- Challenge them to optimize their design for reusability
- Introduce advanced concepts like higher-order functions
For Struggling Students
- Provide more structured guidance on program decomposition
- Offer function templates or starter code
- Focus on clearer function interfaces
Homework/Extension
- Complete the mini-project if not finished in class
- Refactor a previously written program to use a more modular design
- Research modular design patterns in professional software development
Teacher Notes
- Emphasize that modular design is a fundamental software engineering principle
- Watch for overly complex function interfaces or dependencies
- Make connections to real-world software development practices
- Consider discussing how modular design supports team collaboration
- Remind students that the AP Create Performance Task will require good program organization
- This concludes Week 3 of the unit