Patrones de Diseño Creacional Flashcards

(25 cards)

1
Q

What is the main purpose of the Builder pattern?

A

To construct complex objects step by step.

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

True or False: The Singleton pattern allows multiple instances of a class.

A

False

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

Fill in the blank: The _______ pattern provides an interface for creating families of related or dependent objects without specifying their concrete classes.

A

Abstract Factory

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

What is a key characteristic of the Factory Method pattern?

A

It defines an interface for creating an object but allows subclasses to alter the type of objects that will be created.

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

What does the Prototype pattern do?

A

It creates new objects by copying an existing object, known as the prototype.

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

Which creational pattern ensures that a class has only one instance and provides a global point of access to it?

A

Singleton

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

Multiple Choice: Which of the following is NOT a creational pattern? A) Builder B) Observer C) Singleton D) Factory Method

A

B) Observer

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

Short Answer: What is the benefit of using the Builder pattern?

A

It allows for more control over the construction process and can create different representations of an object.

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

True or False: The Abstract Factory pattern can produce different types of objects that are related.

A

True

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

Fill in the blank: In the Factory Method pattern, subclasses are responsible for _______ the objects.

A

creating

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

What is the main advantage of the Prototype pattern?

A

It can be more efficient than creating new instances from scratch, especially for complex objects.

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

Short Answer: How does the Singleton pattern restrict instantiation?

A

It makes the constructor private and provides a static method to get the instance.

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

Multiple Choice: Which pattern is best suited for creating objects without specifying their concrete classes? A) Builder B) Singleton C) Abstract Factory D) Prototype

A

C) Abstract Factory

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

True or False: The Builder pattern can only be used with immutable objects.

A

False

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

Fill in the blank: The _______ pattern allows a class to delegate the responsibility of object creation to its subclasses.

A

Factory Method

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

What is one common use case for the Singleton pattern?

A

Managing shared resources like a configuration object or logging service.

17
Q

Short Answer: What is a disadvantage of the Singleton pattern?

A

It can introduce global state into an application, which may lead to issues in testing and concurrency.

18
Q

Multiple Choice: Which of the following patterns allows for changing the internal representation of an object? A) Builder B) Prototype C) Singleton D) Abstract Factory

19
Q

True or False: The Factory Method pattern can only create one type of object.

20
Q

Fill in the blank: The _______ pattern is useful when a system should be independent of how its products are created, composed, and represented.

A

Abstract Factory

21
Q

What does the Builder pattern help to improve in terms of code quality?

A

Readability and maintainability.

22
Q

Short Answer: In what scenario is the Prototype pattern particularly useful?

A

When creating objects that are expensive to create or require a lot of setup.

23
Q

Multiple Choice: Which pattern is known for its use of a ‘clone’ method? A) Builder B) Singleton C) Prototype D) Factory Method

24
Q

True or False: The Builder pattern can only be used for creating complex objects.

25
Fill in the blank: The _______ pattern allows for the creation of objects that are part of a family of related products.
Abstract Factory