Design Pattern Flashcards
What is concrete Instanciation
It is creation of object using new operator
What is difference between Factory Method & Factory Object
Factory object is instance of class which creates the Concrete Object
Factory method is where the actual instance of class is created
What is recursive composition?
Recursive composition is where composite class is aware of other classes in heirarchy (and may be used to create the certain type of class)
What are principles that are realised using composite pattern?
- Decomposition
- Generalisation
What is aggregation stack?
It is stack of object where the current object knows about the object above it and augment the one below it
What is difference between aggregation and inheritance?
In aggregation, we access behaviour of class using it’s object. Inheritance we inherit behaviour
What is a Structural Design Pattern?
A design pattern that deals with object composition to form larger structures.
True or False: Structural Design Patterns focus on how classes and objects are composed to form larger structures.
True
Name a common Structural Design Pattern.
Adapter Pattern
What is the purpose of the Adapter Pattern?
To allow incompatible interfaces to work together.
Fill in the blank: The ______ Pattern allows an object to alter its behavior when its internal state changes.
State
Which Structural Design Pattern provides a way to compose objects into tree structures to represent part-whole hierarchies?
Composite Pattern
True or False: The Bridge Pattern separates an abstraction from its implementation.
True
What is the main goal of the Decorator Pattern?
To add new functionality to an object dynamically.
Multiple Choice: Which of the following is NOT a Structural Design Pattern? A) Composite B) Observer C) Facade D) Proxy
B) Observer
What does the Facade Pattern provide?
A simplified interface to a complex subsystem.
Fill in the blank: The ______ Pattern allows for lazy initialization of an object.
Proxy
What is the main advantage of using the Flyweight Pattern?
To minimize memory usage by sharing common parts of state among multiple objects.
True or False: The Composite Pattern cannot be used to treat individual objects and compositions uniformly.
False
Which Structural Design Pattern is useful for decoupling an interface from its implementation?
Bridge Pattern
What is the role of a ‘Component’ in the Composite Pattern?
It defines the interface for objects in the composition.
Multiple Choice: In which scenario would you use the Decorator Pattern? A) To create a new class hierarchy B) To add responsibilities to objects dynamically C) To simplify complex systems D) To provide an interface
B) To add responsibilities to objects dynamically
What does the Proxy Pattern allow in terms of access control?
It allows for controlling access to an object by acting as a surrogate.
True or False: The Flyweight Pattern is primarily concerned with reducing the number of objects instantiated.
True