In a Facade Pattern implementation, what is the role of the Facade class?
It defines the interfaces for all classes within the subsystem.
It restricts access to the subsystem, preventing any external interaction.
It directly implements the complex logic of the subsystem.
It delegates requests to appropriate subsystem classes and returns results.
In Python, a common way to implement a Singleton is by using:
Multiple inheritance
Decorators
Interfaces
Abstract classes
Which of the following is a key difference between the Factory Method and Simple Factory patterns?
Factory Method handles object creation centrally, whereas Simple Factory distributes it.
Factory Method uses inheritance, while Simple Factory relies on a single factory class.
Simple Factory promotes extensibility, while Factory Method is less flexible.
Simple Factory is better suited for complex object creation hierarchies.
What is a key benefit of using the Observer pattern?
It makes the code more tightly coupled.
It increases the dependency on concrete classes.
It promotes loose coupling between objects.
It violates the Single Responsibility Principle.
What is a potential drawback of using the Factory Method pattern?
It is not suitable for creating objects from abstract interfaces.
It prevents the use of dependency injection for object creation.
It violates the Open/Closed Principle, making code harder to modify.
It can lead to increased code complexity, especially with many subclasses.
Which of the following is NOT a typical category of design patterns?
Creational
Behavioral
Functional
Structural
In the Observer pattern, what does the 'subject' object do?
Both B and C
Maintains a list of its dependents and notifies them of state changes.
Provides an interface for attaching and detaching observer objects.
Observes the state of other objects.
Which of these is a common real-world analogy used to explain the Decorator Pattern?
Adding toppings to a base coffee or ice cream.
A chain of objects processing a request sequentially.
A factory producing different types of objects.
A tree structure representing hierarchical relationships.
How does the Strategy Pattern promote the Open/Closed Principle?
It allows adding new strategies without modifying the existing Context class.
It prevents modification of existing strategies, ensuring their integrity.
It promotes code reuse by allowing strategies to be shared across multiple contexts.
It reduces the need for inheritance, making the codebase more flexible.
What is a key benefit of using the Strategy Pattern?
Improved code readability and maintainability by separating algorithm logic.
Elimination of conditional statements.
Enhanced security by restricting access to algorithms.
Reduced object creation overhead.