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

Why have we declared the instance reference volatile?

537


What is architecture and what is design?

589


What is the difference between proxy and adapter?

607


What are the main types of concurrency design patterns?

580


What is a lazy initialization in singleton?

594






What are the additional productivity features and enhancements included with Quartus II software version 6.0?

1952


Can you explain singleton pattern?

566


What is the difference between architecture and design?

579


Are you using singleton in your code?

589


2. Create your own definition of a system. Based on the “system” definitions a. Identify your viewpoint of shortcomings in the definitions. b. Provide rationale as to why you believe that your definition overcomes those shortcomings. c. From an historical perspective, identify three precedented systems that were replaced by unprecedented systems.

2720


What is viper architecture?

606


What is the prototype design pattern?

626


What are the SDLC phases you have invloved ?

2176


What are the most popular design patterns?

572


What are the most commonly used design patterns?

598