Activity 01
Pair Programming: Singleton Implementation
Pairs start with a basic class that creates multiple instances. They refactor it to enforce a single instance using the Singleton pattern, test with multiple calls, and log instance counts. Pairs then share one success and one challenge with the class.
Explain how design patterns promote code reusability and maintainability.
Facilitation TipDuring Pair Programming: Singleton Implementation, circulate and ask each pair to explain how their private constructor prevents multiple instances, listening for precise language about class-level control.
What to look forPresent students with three short code examples. Ask them to identify which, if any, demonstrates the Singleton pattern and explain their reasoning. For example, 'Does this code allow multiple instances of `DatabaseManager`? Why or why not?'