1.6.1 Commonly Used Design Patterns
Below are some of the most widely recognized design patterns:
1.6.1.1 Singleton Pattern
The Singleton Design Pattern is a way to make sure that a specific object or resource is created only once in a program and reused whenever needed.
1.6.1.2 Factory Pattern
The Factory Design Pattern is like having a special workshop that knows how to create different products, but you don't need to worry about the details of how those products are made. Instead, you just tell the factory what you need, and it gives you the finished product.
1.6.1.3 Observer Pattern
The Observer Design Pattern is like having a group of people who are interested in getting updates from one particular source. Whenever something important happens, the source automatically notifies all the interested people. It's a way to keep things in sync without everyone constantly checking for updates.
1.6.1.4 Strategy Pattern
The Strategy Design Pattern is like having a toolbox full of different tools, each designed for a specific job. When you face a problem, you can pick the right tool from the box based on the task at hand.
Class Activity
Identify a real-world scenario around you where you can apply one of these design patterns. Share your examples in the next class.