Chapter 30.2 Flashcards

(13 cards)

1
Q

Purpose of the builder pattern

A

To extract the object construction code out of its own class and move it to separate objects called builders

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

A director class

A

-defines the order in which to execute the building steps, while the builder provides the implementation for those steps.

  • hides the details of
    product construction from the client code.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

The IBuilder interface

A

declares product construction steps that are common to
all concrete builders.

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

The concrete builders

A

provide different implementations of the construction steps.

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

Products

A

are objects being created by the builder.

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

The client

A

It must associate one of the builder objects with the director.

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

Advantages of the Builder Pattern

A
  • You can construct objects step-by-step, defer construction steps or run steps recursively.
  • You can reuse the same construction code when building various representations of products.
  • Single Responsibility Principle. You can isolate complex construction code from the
    business logic of the product.
  • It gives finer control over the construction process
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Disadvantages of the Builder Pattern

A

The overall complexity of the code increases since the pattern requires extra classes on top
of the Product.

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

When to use the Builder Pattern

A

-To get rid of multiple overloaded constructors.

Rather use different builders for different combinations of parameters.

-when you want your code to be able to create different
representations of some product

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

The _________assures that there is one and only one instance of a class 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
11
Q

The ________ pattern is used to create a duplicate object or clone of the current object.

A

Prototype

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

The _________ defines an interface or abstract class for the factory class and
allow subclasses thereof (concrete creators) to decide which product class to instantiate.

A

Factory Method pattern

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

The ________ pattern allows the production of concrete products that belong together
in a family.

A

Abstract Factory

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