Which principle of object-oriented design does the Builder Pattern primarily promote?
Liskov Substitution Principle
Open/Closed Principle
Dependency Inversion Principle
Single Responsibility Principle
What is the primary purpose of the Iterator Pattern in software development?
To define a family of algorithms, encapsulate each one, and make them interchangeable.
To provide a way to access elements of an aggregate object sequentially without exposing its underlying representation.
To create objects from a class without specifying the exact class to create.
To ensure that a class has only one instance and provides a global point of access to it.
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 provide a way to access elements of an aggregate object sequentially.
To define a family of algorithms and encapsulate each one.
In a vending machine simulation using the State Pattern, what would likely be a 'State'?
The act of dispensing a product
The number of coins inserted
The 'Out of Stock' condition
The price of a product
How does the Iterator Pattern handle situations where the underlying collection might be modified during iteration?
It creates a copy of the collection to ensure data integrity during iteration.
It relies on the client code to manage synchronization and prevent issues.
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.
Which core method is typically associated with the Prototype Pattern?
create()
clone()
getInstance()
copy()
Which of these is a real-world scenario where the State Pattern is beneficial?
Validating user input in a form.
Representing the different stages of an order in an e-commerce system.
Implementing a simple counter.
Sorting a list of elements in ascending order.
What is a key advantage of using a 'Flyweight Factory' in the pattern?
It provides a centralized point for accessing and managing extrinsic state.
It simplifies the creation of complex Flyweight objects.
It enforces the use of a single instance for each unique Flyweight.
It allows for dynamic loading and unloading of Flyweight objects.
What is a potential drawback of using the State Pattern?
It cannot be used with other design patterns.
It increases code complexity, especially for simple state machines.
It violates the Open/Closed Principle by requiring modification for new states.
It is inefficient for handling a large number of states.
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 represents the collection of objects being iterated over.
It creates objects without exposing the instantiation logic to the client.
It defines the interface for accessing and traversing elements.