When to Use a Factory Pattern?

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


Please Help Members By Posting Answers For Below Questions

What is architecture and what is design?

596


What is the prototype design pattern?

638


Can we have this pattern implemented using static class?

581


When should design patterns be used?

590


what are the creational design patterns

672






What is the singleton design pattern?

633


Quartus II software version 6.0 is available for which operating systems (OS)?

1923


What is singleton and factory pattern?

582


What are useful tools for developing and testing color schemes for web sites?

2030


When singleton pattern is used?

605


What design pattern wrapper classes implement?

616


What are the examples of the behavioral design patterns?

604


What is the creational design pattern?

634


What is meant by design pattern?

585


What are the 23 design patterns?

722