FACTORY METHOD Flashcards

1
Q

Factory Method is a

A

creational design pattern that provides
an interface for creating objects in a superclass, 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
2
Q

What does the Factory Method pattern suggest?

A

It suggests replacing direct object construction calls with calls to a special factory method.

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

What should you replace when using the Factory Method pattern?

A

Replace direct object construction calls using the new operator.

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

What is used instead of the new operator in the Factory Method pattern?

A

A special factory method is used.

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

the factory method in the base
class should have its return type declared as

A

this interface.

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

The Product

A

declares the interface, which is common to all objects that can be produced by the creator and its subclasses.

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

Concrete Products

A

are different implementations of the product interface.

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

The Creator class

A

declares the factory method that returns
new product objects. It’s important that the return type of this
method matches the product interface.

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

Concrete Creators

A

override the base factory method so it
returns a different type ofproduct.

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

Use the Factory Method when you don’t know beforehand

A

the exact types and dependencies of the objects your code should
work with.

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

The Factory Method separates

A

product construction code from
thecodethatactuallyusestheproduct.Thereforeit’seasierto
extend the product construction code independently from the
rest of the code.

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

Use the Factory Method when you want to provide users

A

of your library or framework with a way to extend its internal
components.

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

how would the frame-
work recognize that your subclass should be used instead of a
standard component?

A

The solution is to reduce the code that constructs components across the framework into a single factory method and let anyone override this method in addition to extending the component itself.

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