What is the primary goal of the Flyweight pattern?
To encapsulate algorithms in objects, allowing for easy swapping and extension.
To minimize memory usage by sharing common data among multiple objects.
To provide a way to access shared objects in a synchronized manner.
To define a family of algorithms, encapsulate each one, and make them interchangeable.
In the State Pattern, what does the 'Context' class represent?
The mechanism for transitioning between states.
The concrete classes implementing different states.
The interface or abstract class defining state-specific actions.
The class that holds the current state of the object.
What is the primary purpose of the Proxy Pattern in software design?
To control access to an object, potentially restricting its use.
To allow objects to be notified of changes in other objects.
To define a family of algorithms and encapsulate each one.
To provide a simplified interface to a complex subsystem.
Which aspect of the Proxy Pattern implementation often involves using an interface?
The Proxy and the real subject implementing a common interface.
The Proxy serializing and deserializing access to the real subject.
The Proxy dynamically loading the real subject using reflection.
The client only interacting with the Proxy through an abstract factory.
What type of relationship does the Composite pattern leverage to represent the parent-child structure?
Inheritance
Dependency
Aggregation
Composition
Which real-world scenario is well-suited for the Composite pattern?
Creating a thread-safe singleton object.
Representing a file system with directories and files.
Implementing an undo/redo mechanism.
Managing a database connection pool.
Which principle of object-oriented design does the Iterator Pattern promote by decoupling the traversal mechanism from the aggregate object?
Open/Closed Principle
Dependency Inversion Principle
Single Responsibility Principle
Liskov Substitution Principle
In the Builder Pattern, what is the product?
The concrete builder class that assembles the object.
The complex object being constructed.
The director class that orchestrates the building process.
The interface that defines the building steps.
What could be a potential drawback of using the Flyweight pattern?
Increased memory consumption due to object duplication.
Slower performance because of the overhead of managing shared objects.
Limited flexibility in handling object variations and customizations.
Reduced code readability due to the separation of intrinsic and extrinsic state.
What is a key advantage of encapsulating state-specific behavior in separate classes in the State Pattern?
It eliminates the need for interfaces or abstract classes.
It reduces the number of classes needed compared to other patterns.
It improves code organization and allows for easier addition of new states.
It makes the code more concise and harder to understand.