How does the Facade Pattern contribute to the principle of loose coupling?
It reduces the dependencies between the client and the complex subsystem.
It eliminates the need for any coupling between classes.
It introduces cyclic dependencies to improve code reusability.
It tightly couples the client to the subsystem's implementation details.
In Python, a common way to implement a Singleton is by using:
Multiple inheritance
Interfaces
Abstract classes
Decorators
Which principle of object-oriented design does the Decorator Pattern promote most effectively?
Single Responsibility Principle
Dependency Inversion Principle
Liskov Substitution Principle
Open/Closed Principle
Which principle of object-oriented design does the Adapter Pattern primarily promote?
Composition
Encapsulation
Polymorphism
Inheritance
Which of the following is a potential drawback of the Singleton pattern?
It simplifies dependency injection.
It makes unit testing more challenging.
It reduces the need for global variables.
It promotes code reusability.
In the context of the Decorator Pattern, what is the relationship between the 'ConcreteComponent' and 'Decorator'?
The ConcreteComponent inherits from the Decorator.
There is no direct relationship between them.
The Decorator inherits from the ConcreteComponent.
Both the Decorator and ConcreteComponent implement the same interface.
Which type of design pattern deals with object creation mechanisms?
Architectural
Creational
Behavioral
Structural
Which of the following scenarios best exemplifies the use of the Strategy Pattern?
Logging system events to a file or a database based on configuration.
Implementing different validation rules for a user input field based on context.
Creating a single, universal sorting algorithm for all data types.
Representing a complex object structure as a hierarchical tree.
When is it appropriate to consider using the Facade Pattern?
When you want to expose the internal implementation details of a system.
When you need to simplify the interface to a complex subsystem.
When the interaction with a subsystem is already simple and straightforward.
When dealing with a small, well-defined set of classes.
Which of the following is NOT a typical use case for the Adapter Pattern?
Implementing a new sorting algorithm for a data structure.
Using third-party libraries with incompatible interfaces.
Integrating legacy code with a modern system.
Creating a reusable component that can work with various data sources.