Design Pattern Glossary (OOD)
Common design patterns used in Object-Oriented Design interviews to solve recurring problems.
Creational Patterns
How objects are created.
- Factory Pattern: used in Chess Game to create pieces without specifying their concrete classes.
- Singleton Pattern: used in the Elevator System for the system controller to ensure only one instance handles dispatching.
Structural Patterns
How objects are composed.
- Composite Pattern: used in the File System to treat files and directories uniformly.
- Decorator Pattern: used in the Online Shopping System for adding shipping options (insurance, express) to an order.
Behavioral Patterns
How objects communicate.
- State Pattern: used in Vending Machine and ATM System to manage complex lifecycles.
- Strategy Pattern: used in Parking Lot for different pricing algorithms and Online Shopping for payment methods.
- Observer Pattern: used in Stack Overflow for notifying users of new activity.
[!TIP] Don't over-engineer! Apply patterns only when they solve a specific problem like "handling many if-else blocks" or "decoupling providers."