Activity 01
Pair Programming: Refactor a Monolith
Provide students with a long script full of repeated code, such as a basic calculator. In pairs, identify duplicate sections, extract them into functions with parameters, test each function separately, then integrate and run the full program. Pairs present one key change and its impact.
Analyze how modularity improves the reliability and readability of a program?
Facilitation TipDuring Pair Programming: Refactor a Monolith, require students to track line counts and error logs before and after refactoring to make the benefits of modularity visible.
What to look forProvide students with a short Python script that performs a simple task (e.g., calculating the area of different shapes). Ask them to identify one section of code that could be refactored into a function and explain why. For example: 'Identify the code block that calculates the area of a rectangle. Explain how turning this into a function named 'calculate_rectangle_area' would improve the code.'