Answer Posted / guest
A class can?t anticipate which kind of class of objects it
must create.
A class uses its subclasses to specify which objects it creates.
You want to localize the knowledge of which class gets created.
There are several similar variations on the factory pattern
to recognize.
1. The base class is abstract and the pattern must return a
complete working class.
2. The base class contains default methods and is only
subclassed for cases where the default methods are insufficient.
3. Parameters are passed to the factory telling it which of
several class types to return. In this case the classes may
share the same method names but may do something quite
different.
| Is This Answer Correct ? | 6 Yes | 0 No |
Post New Answer View All Answers
What is the difference between adapter and facade?
Can you explain singleton pattern?
What are the disadvantages of singleton pattern?
What are creational design patterns?
What is the use of design patterns?
What is the behavioral design pattern?
Give me example of chain of responsibility design pattern?
What are the 23 design patterns?
What is the difference between builder and composite?
What is the design pattern?
Shall we use abstract classes or interfaces in policy / strategy design pattern?
What is use case in clean architecture?
What are the most important software design patterns?
Why is singleton bad?
What is synchronizer token pattern?