Activity 01
Collaborative Lab: Build a Generic Container
Student pairs first implement a non-generic IntBox class that stores and retrieves an integer, then refactor it into a generic Box<T> class. They test it with at least three different data types and document one scenario where the non-generic version would require duplicated code. Pairs share their test cases with another pair for cross-review and comparison.
Justify the need for generic programming in building flexible and reusable software components.
Facilitation TipDuring the Collaborative Lab, circulate and ask each group to explain how their type parameter relates to the container’s operations before they run their first test.
What to look forPresent students with code snippets of a generic class (e.g., `Box<T>`) and a non-generic class (e.g., `ObjectBox`). Ask them to identify which is generic and explain in one sentence why the generic version is preferred for type safety and reusability.