Patrones de Comportamiento Flashcards

(25 cards)

1
Q

What design pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable?

A

Strategy Pattern

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

True or False: The Memento Pattern allows an object to capture its internal state without violating encapsulation.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the main purpose of the Observer Pattern?

A

To define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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.

A

chain

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Which pattern allows adding new behaviors to objects dynamically without altering their structure?

A

Visitor Pattern

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

True or False: The Command Pattern encapsulates a request as an object, thereby allowing parameterization of clients with queues, requests, and operations.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What pattern is used to encapsulate state-based behavior in an object?

A

State Pattern

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

In the Mediator Pattern, what role does the mediator play?

A

It facilitates communication between different objects without them needing to reference each other directly.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What design pattern provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation?

A

Iterator Pattern

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Which design pattern is best suited for implementing undo functionality?

A

Memento Pattern

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

True or False: In the Observer Pattern, the subject must maintain a list of observers to notify them of state changes.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a key benefit of using the Strategy Pattern?

A

It promotes the use of composition over inheritance.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Fill in the blank: The ___ Pattern allows an object to change its behavior when its internal state changes.

A

State

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Which pattern is often used to implement a logging system where different loggers can be added or removed at runtime?

A

Chain of Responsibility Pattern

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the main advantage of using the Visitor Pattern?

A

It separates an algorithm from the object structure on which it operates.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

True or False: The Command Pattern can be used to implement transactional behavior.

17
Q

What is the primary function of the Mediator Pattern?

A

To reduce the coupling between components by introducing a mediator object.

18
Q

Which pattern allows a client to request an action without knowing the specifics of the action being performed?

A

Command Pattern

19
Q

Fill in the blank: The ___ Pattern allows for the creation of a single point of control for complex interactions between objects.

20
Q

What does the Iterator Pattern allow you to do?

A

Traverse a collection without exposing its underlying structure.

21
Q

True or False: The Strategy Pattern can lead to an increase in the number of classes in a system.

22
Q

What pattern would you use to implement the functionality of ‘saving’ and ‘restoring’ an object’s state?

A

Memento Pattern

23
Q

Fill in the blank: The ___ Pattern is particularly useful for handling events in a GUI application.

24
Q

What is a common use case for the State Pattern?

A

To manage the states of a user session in a web application.

25
Which pattern can be used to decouple the sender of a request from its receivers?
Command Pattern