Define Singleton pattern.
A design pattern that restricts a class to a single instance.
True or false: The Observer pattern allows objects to notify others of state changes.
TRUE
Commonly used in event handling systems.
What is the purpose of the Factory pattern?
To create objects without specifying the exact class of object that will be created.
Fill in the blank: The Decorator pattern adds ______ to objects dynamically.
Responsibilities
Define Strategy pattern.
A design pattern that enables selecting an algorithm’s behavior at runtime.
What does the Facade pattern provide?
A simplified interface to a complex subsystem.
True or false: The Command pattern encapsulates a request as an object.
TRUE
This allows for parameterization and queuing of requests.
Define Adapter pattern.
A design pattern that allows incompatible interfaces to work together.
What is the Builder pattern used for?
To construct complex objects step by step.
Fill in the blank: The Prototype pattern creates new objects by ______.
Copying existing ones
Define Composite pattern.
A design pattern that allows treating individual objects and compositions uniformly.
What does the Chain of Responsibility pattern do?
It passes a request along a chain of handlers.
True or false: The State pattern allows an object to alter its behavior when its state changes.
TRUE
This pattern is useful for implementing state machines.
Define Mediator pattern.
A design pattern that facilitates communication between objects without them referring to each other.
What is the Template Method pattern?
A design pattern that defines the skeleton of an algorithm in a method.
Fill in the blank: The Visitor pattern lets you add new operations without changing ______.
The classes of the elements
Define Memento pattern.
A design pattern that captures and externalizes an object’s internal state.
What does the Interpreter pattern do?
It defines a representation for a language’s grammar and provides an interpreter.
True or false: The Bridge pattern separates an abstraction from its implementation.
TRUE
This allows both to evolve independently.
Define Proxy pattern.
A design pattern that provides a surrogate or placeholder for another object.
What is the Flyweight pattern used for?
To minimize memory usage by sharing common parts of state among multiple objects.
Fill in the blank: The Iterator pattern provides a way to access elements of a collection ______.
Sequentially
Define Observer pattern.
A design pattern where an object (subject) maintains a list of dependents (observers) that are notified of state changes.
What does the Null Object pattern do?
It uses a special object that represents ‘no action’ instead of null references.