Read each real-world scenario and identify: What's the problem? Which design pattern solves it? Why?
No coding required - focus on understanding which pattern fits which problem!
The Situation:
TechCo manufactures smartphones. Their production system code looks like this:
The Situation:
ShipFast provides multiple shipping options. Their cost calculation system looks like this:
The Situation:
Sarah has a smart home security system. When a motion sensor detects movement, she needs multiple systems to respond:
Her current code:
The Situation:
EcomSite has an online store. They have a ShoppingCart class for user purchases:
After completing all four scenarios, discuss these questions as a group:
Use this AFTER you've made your guesses!
When you need to create different types of similar products without massive if/else chains
When you need to switch between different methods for accomplishing the same goal
When one event needs to notify many systems automatically
When you need exactly ONE shared instance that everyone accesses
Remember: Patterns solve problems. Focus on understanding WHICH pattern solves WHICH problem!
You'll see the code implementations after the breakout. Concepts first! 🎯