Real-World Guide to Factory, Strategy, Observer & Singleton Patterns
"Creates different things based on what you ask for"
Restaurant kitchen - order by name, kitchen makes it
Creating many similar things without knowing all the complex details
✓ Many similar types to create
✓ Creation is complex
✓ Need to add new types easily
✗ Only one type exists
✗ Creation is simple
"Switching between different ways to do the same task"
GPS routes - fastest, scenic, or avoid highways
Need different approaches for same goal that you can switch between
✓ Multiple ways to do same thing
✓ Need to switch at runtime
✓ Want to avoid messy if/else chains
✗ Only one approach exists
✗ Approach never changes
"When something happens, notify everyone who cares"
YouTube subscriptions - upload once, all subscribers notified
One event needs to trigger multiple reactions automatically
✓ One change affects many objects
✓ Want loose coupling
✓ Listeners join/leave dynamically
✗ Only one thing needs notification
✗ Direct communication is fine
"Ensuring there's only ONE of something"
Company CEO - one leader, everyone refers to same person
Need exactly one shared instance that everyone accesses
✓ Need exactly ONE instance
✓ Shared resource required
✓ Changes should be universal
✗ Multiple instances might be needed
✗ "Just to be safe" (misused often!)