Patrones de Comportamiento Flashcards
(25 cards)
What design pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable?
Strategy Pattern
True or False: The Memento Pattern allows an object to capture its internal state without violating encapsulation.
True
What is the main purpose of the Observer Pattern?
To define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified.
Fill in the blank: The Chain of Responsibility Pattern allows multiple handlers to process a request without the sender knowing which handler will handle it, creating a ___ of handlers.
chain
Which pattern allows adding new behaviors to objects dynamically without altering their structure?
Visitor Pattern
True or False: The Command Pattern encapsulates a request as an object, thereby allowing parameterization of clients with queues, requests, and operations.
True
What pattern is used to encapsulate state-based behavior in an object?
State Pattern
In the Mediator Pattern, what role does the mediator play?
It facilitates communication between different objects without them needing to reference each other directly.
What design pattern provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation?
Iterator Pattern
Which design pattern is best suited for implementing undo functionality?
Memento Pattern
True or False: In the Observer Pattern, the subject must maintain a list of observers to notify them of state changes.
True
What is a key benefit of using the Strategy Pattern?
It promotes the use of composition over inheritance.
Fill in the blank: The ___ Pattern allows an object to change its behavior when its internal state changes.
State
Which pattern is often used to implement a logging system where different loggers can be added or removed at runtime?
Chain of Responsibility Pattern
What is the main advantage of using the Visitor Pattern?
It separates an algorithm from the object structure on which it operates.
True or False: The Command Pattern can be used to implement transactional behavior.
True
What is the primary function of the Mediator Pattern?
To reduce the coupling between components by introducing a mediator object.
Which pattern allows a client to request an action without knowing the specifics of the action being performed?
Command Pattern
Fill in the blank: The ___ Pattern allows for the creation of a single point of control for complex interactions between objects.
Mediator
What does the Iterator Pattern allow you to do?
Traverse a collection without exposing its underlying structure.
True or False: The Strategy Pattern can lead to an increase in the number of classes in a system.
True
What pattern would you use to implement the functionality of ‘saving’ and ‘restoring’ an object’s state?
Memento Pattern
Fill in the blank: The ___ Pattern is particularly useful for handling events in a GUI application.
Observer
What is a common use case for the State Pattern?
To manage the states of a user session in a web application.