What could be a potential drawback of using the Flyweight pattern?
Limited flexibility in handling object variations and customizations.
Slower performance because of the overhead of managing shared objects.
Increased memory consumption due to object duplication.
Reduced code readability due to the separation of intrinsic and extrinsic state.
What is the primary goal of the State Pattern in object-oriented programming?
To create objects without specifying their concrete classes.
To manage and transition between different states of an object.
To define a family of algorithms and encapsulate each one.
To provide a way to access elements of an aggregate object sequentially.
Which principle of object-oriented design does the State Pattern primarily promote?
Open/Closed Principle
Liskov Substitution Principle
Dependency Inversion Principle
Single Responsibility Principle
In the context of the Proxy Pattern, what does the term 'subject' refer to?
The object that controls access to the real object.
The interface shared by the proxy and the real object.
The client that interacts with the proxy or the real object.
The object being accessed through the proxy.
In a language like Java, how is object cloning often achieved within the Prototype Pattern?
By directly copying object properties.
By implementing the Cloneable interface.
Cloneable
By using the spread operator.
spread
By using the Object.assign() method.
Object.assign()
How does the Iterator Pattern handle situations where the underlying collection might be modified during iteration?
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.
It generally does not handle this directly; safeguards like concurrent modification exceptions might be needed.
It automatically prevents any modifications to the collection while iteration is in progress.
In a typical Iterator Pattern implementation, what is the role of the 'ConcreteIterator' class?
It creates objects without exposing the instantiation logic to the client.
It represents the collection of objects being iterated over.
It implements the Iterator interface and provides the concrete implementation for iterating over a specific aggregate object.
It defines the interface for accessing and traversing elements.
What is a potential drawback of using the State Pattern?
It violates the Open/Closed Principle by requiring modification for new states.
It increases code complexity, especially for simple state machines.
It is inefficient for handling a large number of states.
It cannot be used with other design patterns.
What is the primary goal of the Flyweight pattern?
To provide a way to access shared objects in a synchronized manner.
To encapsulate algorithms in objects, allowing for easy swapping and extension.
To define a family of algorithms, encapsulate each one, and make them interchangeable.
To minimize memory usage by sharing common data among multiple objects.
Which of these scenarios is a good candidate for using the Proxy Pattern?
Creating objects that are only instantiated when actually needed.
Representing a complex object hierarchy in a simplified manner.
Defining a one-to-many dependency between objects.
Iterating over a collection of objects without exposing its structure.