Which of the following is a key difference between the Factory Method and Simple Factory patterns?
Simple Factory promotes extensibility, while Factory Method is less flexible.
Factory Method handles object creation centrally, whereas Simple Factory distributes it.
Simple Factory is better suited for complex object creation hierarchies.
Factory Method uses inheritance, while Simple Factory relies on a single factory class.
In a text editor, how might the Strategy Pattern be applied to handle different text formatting options (bold, italic, underline)?
The Strategy Pattern wouldn't be suitable for this scenario.
Each formatting style (bold, italic, underline) could be a separate strategy class.
A single formatting function could handle all styles using conditional statements.
The editor could use a factory to create different formatting objects based on user input.
How does the Command Pattern support the implementation of an 'undo' functionality?
By directly modifying the state of the application to revert changes.
By relying on the operating system's built-in undo functionality.
By providing a mechanism to reverse the actions performed by a command.
By preventing any actions from being executed in the first place.
What is a potential drawback of using the Adapter Pattern?
It can lead to performance issues due to the overhead of adaptation.
It can make the code more complex, especially with multiple adapters.
It violates the Open/Closed Principle.
It is not suitable for adapting interfaces with many methods.
Can you have multiple Facade classes for a single complex subsystem?
Yes, you can have different Facades exposing tailored functionalities.
It's possible but not recommended as it violates the pattern's principles.
No, the Facade Pattern restricts to only one Facade class.
Multiple Facades can only be used with abstract classes, not concrete ones.
What is the primary intent of the Facade Pattern in software design?
To define a family of algorithms and encapsulate each one.
To provide a simplified interface to a complex subsystem.
To expose low-level implementation details to clients.
To create new functionalities within existing classes.
What is the fundamental purpose of the Singleton design pattern?
To ensure that a class has only one instance.
To provide a way to access the elements of an aggregate object sequentially.
To create multiple instances of a class with different properties.
How does the Facade Pattern contribute to the principle of loose coupling?
It introduces cyclic dependencies to improve code reusability.
It tightly couples the client to the subsystem's implementation details.
It eliminates the need for any coupling between classes.
It reduces the dependencies between the client and the complex subsystem.
Which object-oriented principle does the Factory Method pattern primarily promote?
Dependency Inversion Principle
Open/Closed Principle
Single Responsibility Principle
Liskov Substitution Principle
What is the primary intent of the Strategy Pattern in software design?
To provide a way to access elements of an aggregate object sequentially.
To define a family of algorithms and encapsulate each one for interchangeable use.
To ensure that a class has only one instance and provides a global point of access to it.
To encapsulate data and behavior together in a single unit.