What type of relationship does the Composite pattern leverage to represent the parent-child structure?
Inheritance
Aggregation
Composition
Dependency
Which of these is NOT a common use case for the Prototype Pattern?
Implementing a factory method pattern.
Building systems with dynamic object creation based on user input.
Creating objects with complex initialization logic.
Maintaining a cache of frequently used objects for performance optimization.
Which of these scenarios is a good candidate for using the Proxy Pattern?
Creating objects that are only instantiated when actually needed.
Iterating over a collection of objects without exposing its structure.
Defining a one-to-many dependency between objects.
Representing a complex object hierarchy in a simplified manner.
In the context of the Proxy Pattern, what does the term 'subject' refer to?
The client that interacts with the proxy or the real object.
The object being accessed through the proxy.
The object that controls access to the real object.
The interface shared by the proxy and the real object.
In which scenarios is the Iterator Pattern particularly valuable?
All of the above.
When multiple algorithms need to operate on a collection without knowledge of its internal structure.
When the internal representation of a collection is subject to change.
When you want to provide a consistent way to traverse elements regardless of the collection type.
How does the Builder Pattern differ from using telescoping constructors?
The Builder Pattern is less flexible when dealing with optional attributes.
Telescoping constructors are more readable for a large number of attributes.
The Builder Pattern provides better control and clarity when building objects with many attributes.
Telescoping constructors are preferred when the object construction is complex.
In the Builder Pattern, what is the product?
The complex object being constructed.
The concrete builder class that assembles the object.
The director class that orchestrates the building process.
The interface that defines the building steps.
How does the Iterator Pattern handle situations where the underlying collection might be modified during iteration?
It automatically prevents any modifications to the collection while iteration is in progress.
It generally does not handle this directly; safeguards like concurrent modification exceptions might be needed.
It relies on the client code to manage synchronization and prevent issues.
It creates a copy of the collection to ensure data integrity during iteration.
In a typical Iterator Pattern implementation, what is the role of the 'ConcreteIterator' class?
It implements the Iterator interface and provides the concrete implementation for iterating over a specific aggregate object.
It creates objects without exposing the instantiation logic to the client.
It defines the interface for accessing and traversing elements.
It represents the collection of objects being iterated over.
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.