In what situation factory design patterns,DAO design
patterns,singleton design patterns should be applied.?
Answer Posted / rajan
Unlike constructors, factory methods are not required to
create a new object each time they are invoked. Factory
methods can encapsulate the logic required to return a
singleton instance of the class requested, or they can
return an instance of the requested class from a pool of
instances.
Factory methods can return any subtype of the type
requested, and can require that clients refer to the
returned object by its interface, rather than the
implementation class. This enables an API to return objects
without making their classes public.
The class for the object returned by a factory method need
not even exist at the time the factory method is written.
This is one of the classic benefits of polymorphism: "old
code uses new code," which means that new classes can be
added, and their instances returned by the factory method,
without changing any of the existing code.
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
What are benefits of oop?
Can we create object of abstract class?
What is multilevel inheritance?
What are objects in oop?
They started with the brief introduction followed by few basic C++ questions on polumorphism, inheritance and then virtual functions. What is polymorphims? How you will access polymorphic functions in C? How virtual function mechanism works?
Why do we use class in oops?
What is the difference between inheritance and polymorphism?
What is polymorphism what are the different types of polymorphism?
What is difference between polymorphism and inheritance?
Is react oop?
Please send ford technologies placement paper 2 my mail id
Which method cannot be overridden?
What is abstraction oop?
How do you define social class?
i am getting an of the type can not convert int to int *. to overcome this problem what we should do?