How does the Flyweight pattern contribute to object-oriented design principles?
It enhances code reusability by encapsulating common behavior in shared objects.
All of the above.
It promotes loose coupling by separating object creation from usage.
It improves performance by reducing the number of objects instantiated.
How does the Iterator Pattern contribute to code maintainability?
By defining a family of algorithms and making them interchangeable.
By encapsulating the iteration logic and abstracting the aggregate structure, making changes to either independently easier.
By providing a global point of access to a single instance.
By centralizing object creation logic.
What is the primary purpose of the Proxy Pattern in software design?
To provide a simplified interface to a complex subsystem.
To control access to an object, potentially restricting its use.
To allow objects to be notified of changes in other objects.
To define a family of algorithms and encapsulate each one.
How does the State Pattern typically handle state transitions?
A separate 'State Manager' class controls all transitions.
The 'Context' object directly modifies its internal state.
State transitions are determined by external events only.
State objects have methods to trigger transitions to other states.
What could be a potential drawback of using the Flyweight pattern?
Slower performance because of the overhead of managing shared objects.
Reduced code readability due to the separation of intrinsic and extrinsic state.
Increased memory consumption due to object duplication.
Limited flexibility in handling object variations and customizations.
A Remote Proxy is typically used for:
Providing a local representation of an object in a different process.
Creating a placeholder for an object that hasn't been fully loaded.
Controlling access to the real subject based on user roles.
Caching the results of expensive operations for performance improvement.
How does the Iterator Pattern handle situations where the underlying collection might be modified during iteration?
It generally does not handle this directly; safeguards like concurrent modification exceptions might be needed.
It creates a copy of the collection to ensure data integrity during iteration.
It automatically prevents any modifications to the collection while iteration is in progress.
It relies on the client code to manage synchronization and prevent issues.
What is the primary intent of the Composite Design Pattern?
To ensure a class has only one instance.
To treat individual objects and compositions of objects uniformly.
To provide a way to access the elements of an aggregate object sequentially.
To define a family of algorithms, encapsulate each one, and make them interchangeable.
How does the Builder Pattern differ from using telescoping constructors?
The Builder Pattern is less flexible when dealing with optional attributes.
The Builder Pattern provides better control and clarity when building objects with many attributes.
Telescoping constructors are more readable for a large number of attributes.
Telescoping constructors are preferred when the object construction is complex.
Which principle of object-oriented design does the State Pattern primarily promote?
Open/Closed Principle
Single Responsibility Principle
Liskov Substitution Principle
Dependency Inversion Principle