What is a potential drawback of using the Factory Method pattern?
It violates the Open/Closed Principle, making code harder to modify.
It can lead to increased code complexity, especially with many subclasses.
It is not suitable for creating objects from abstract interfaces.
It prevents the use of dependency injection for object creation.
Which of these is NOT a benefit of using design patterns?
Improved code readability
Increased code duplication
Enhanced code maintainability
Facilitated code reuse
In the Observer pattern, how are observers typically notified of changes?
Using a message queue.
By directly accessing the subject's state variables.
Through a method call on the observer object.
By sending an email notification.
What is a potential drawback of using the Adapter Pattern?
It can make the code more complex, especially with multiple adapters.
It violates the Open/Closed Principle.
It can lead to performance issues due to the overhead of adaptation.
It is not suitable for adapting interfaces with many methods.
In a scenario where you are designing a game with different enemy types, how might the Factory Method pattern be applied?
Hardcode the instantiation of each enemy type directly within the game logic where needed.
Use a dependency injection framework to inject concrete enemy instances into the game logic.
Create a single factory class responsible for instantiating all enemy types based on given parameters.
Define an abstract 'EnemyFactory' with a 'createEnemy' method, and have subclasses for each enemy type implement their creation logic.
What is a key benefit of using the Strategy Pattern?
Improved code readability and maintainability by separating algorithm logic.
Elimination of conditional statements.
Reduced object creation overhead.
Enhanced security by restricting access to algorithms.
In the context of the Decorator Pattern, what is the relationship between the 'ConcreteComponent' and 'Decorator'?
The Decorator inherits from the ConcreteComponent.
There is no direct relationship between them.
The ConcreteComponent inherits from the Decorator.
Both the Decorator and ConcreteComponent implement the same interface.
Which of these scenarios best illustrates a use case for the Singleton pattern?
Displaying different product variations on an e-commerce site.
Managing a database connection pool for an application.
Creating multiple user accounts for a website.
Implementing a sorting algorithm for a list of numbers.
How does the Facade Pattern contribute to the principle of loose coupling?
It eliminates the need for any coupling between classes.
It reduces the dependencies between the client and the complex subsystem.
It tightly couples the client to the subsystem's implementation details.
It introduces cyclic dependencies to improve code reusability.
What is the main difference between Object Adapter and Class Adapter?
There is no difference, both are implemented the same way.
Class Adapter uses inheritance, while Object Adapter uses composition.
Object Adapter uses inheritance, while Class Adapter uses composition.
Object Adapter is suitable for adapting concrete classes, while Class Adapter is for interfaces.