When to Use a Factory Pattern?
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
. Run us through your design process.
when performing a functional test on a phone calculator,if pressing on a button does not function what do i do next
What are the benefits of the proxy in the design pattern?
What are the design patterns you know explain?
Explain the singleton, facade, or handle class design pattern?
. How do you manage timelines?
How to add CSS styles Styles to Elements with Particular Attributes?
4. Identify and bound the SOI’s Operating Environment.
What are the categories in which the design patterns can be divided?
Did you use ooa/ood methodologies? Did you use design patterns?
Describe the builder design pattern
what is diffrence between Function Oriented Design and Obeject Oriented design
11 Answers IBS, TCS,