Design Patterns in C++ Flashcards
1
Q
Types of design patterns
A
- Creational
- Behavioral
- Structural
2
Q
Factory design pattern
A
It creates objects for you rather than you creating objects. It is also known as Virtual Constructor. Define an interface or an abstract class for creating an object but let the subclass decide which class to initiate. Creating objects at runtime.
3
Q
Abstract Factory design pattern
A
AFDP defines an abstract class for creating families of related objects but without specifying their concrete sub-class. You need system to be independent of how objects are created, composed and represented. Show interface not implementation.System need to be configured with one of the multiple family of objects.
4
Q
Singleton pattern
A
Define a class that has only one instance and provide a global point of access to that instance. Save memory, flexible and single point of access. Eg: threadpool, database application, configuration settings. How to implement: 1.static member 2.private constructor 3.Static function