Activity 01
Pairs Refactor: Cohesion Challenge
Give pairs a code snippet with mixed responsibilities, like a class handling both data storage and user interface. They identify issues, separate functions into cohesive modules, and test the refactored version. Pairs then swap with another duo for feedback.
Explain how modularity and abstraction contribute to robust software design.
Facilitation TipDuring Pairs Refactor: Cohesion Challenge, circulate and ask each pair to verbalize one rule they applied while splitting their class into smaller, focused components.
What to look forPresent students with two short code snippets, one demonstrating high cohesion and low coupling, the other demonstrating the opposite. Ask students to identify which snippet is better designed and provide one specific reason, referencing cohesion or coupling.