Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


When to Use a Factory Pattern?

Answers were Sorted based on User's Feedback



When to Use a Factory Pattern?..

Answer / 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

When to Use a Factory Pattern?..

Answer / md. nasim ahmed

The conventional polymorphism approach can also be used to reach the desired result of handling different class object with same set of methods. But the problem is the driver (main/module) must handle the creation of type of object.
CBase *bptr=new CChild();
bptr->method1();
----
The Factory design pattern ease the programming effort to write the driver program as the creation of object is handled by base class only(factory class).
CBase *bptr= CBase::make_object(chioce);

----
Now refer http://sourcemaking.com/design_patterns/factory_method/cpp/1

Is This Answer Correct ?    4 Yes 0 No

When to Use a Factory Pattern?..

Answer / abhishek kumar

Factory pattern will be used when a creator class works
parallel with the product class

Is This Answer Correct ?    3 Yes 2 No

Post New Answer

More Design Patterns Interview Questions

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

0 Answers   IBM,


What is the S/W model used in the project. What are the optimization techniques used. Give examples ?

2 Answers   Infosys, Symphony, Wipro,


Can we have this pattern implemented using static class?

0 Answers  


What is the publish/subscribe model?

1 Answers  


What is meant by design pattern?

0 Answers  


If i make my selection in State Dropdown list, i would the City and ZipCode dropdown list to be automatically reupdated based on the State i select.(This to avoid the user select a City or Zipcode that does not correspond to the State previously selected.)

1 Answers  


What is difference between function oriented design and object oriented design?

0 Answers  


What are the different types of Design Patterns and Explain them?

3 Answers   Genpact, Gradatim, Gul Ahmed, TCS, Wipro,


What are the biggest trends in UX Design these days?

3 Answers  


i have file(ps),dont know how many records are there. move half of the records to 2 files. how can we do

1 Answers   IBM, Infosys,


What are the differences between the design patterns and the framework?

0 Answers  


What is a pattern library?

1 Answers  


Categories