Which principle of object-oriented design does the Builder Pattern primarily promote?
Liskov Substitution Principle
Single Responsibility Principle
Dependency Inversion Principle
Open/Closed Principle
In the Builder Pattern, what is the product?
The director class that orchestrates the building process.
The complex object being constructed.
The concrete builder class that assembles the object.
The interface that defines the building steps.
What could be a potential drawback of using the Flyweight pattern?
Slower performance because of the overhead of managing shared objects.
Increased memory consumption due to object duplication.
Limited flexibility in handling object variations and customizations.
Reduced code readability due to the separation of intrinsic and extrinsic state.
How does the Builder Pattern differ from using telescoping constructors?
Telescoping constructors are preferred when the object construction is complex.
The Builder Pattern is less flexible when dealing with optional attributes.
Telescoping constructors are more readable for a large number of attributes.
The Builder Pattern provides better control and clarity when building objects with many attributes.
What is the primary goal of the Flyweight pattern?
To provide a way to access shared objects in a synchronized manner.
To define a family of algorithms, encapsulate each one, and make them interchangeable.
To minimize memory usage by sharing common data among multiple objects.
To encapsulate algorithms in objects, allowing for easy swapping and extension.
What type of relationship does the Composite pattern leverage to represent the parent-child structure?
Aggregation
Dependency
Composition
Inheritance
How does the State Pattern typically handle state transitions?
The 'Context' object directly modifies its internal state.
State objects have methods to trigger transitions to other states.
A separate 'State Manager' class controls all transitions.
State transitions are determined by external events only.
What is a key advantage of using a 'Flyweight Factory' in the pattern?
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.
It provides a centralized point for accessing and managing extrinsic state.
How does the State Pattern differ from a simple switch statement for managing state?
The State Pattern is less verbose than using a switch statement.
The State Pattern is only suitable for complex state machines.
A switch statement is more aligned with object-oriented principles.
The State Pattern distributes state-specific logic, improving maintainability.
Which of these is NOT a common use case for the Prototype Pattern?
Maintaining a cache of frequently used objects for performance optimization.
Implementing a factory method pattern.
Building systems with dynamic object creation based on user input.
Creating objects with complex initialization logic.