Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Design pattern question

 
Sreedevi Vinod
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is another question from the Whizlabs simulator.
"Which design pattern should you use when you need to create objects without knowing either their exact class or how to create them?"

A. Abstract Factory
B. Builder
C. Factory Method
D. Prototype
E. Singleton

The answer says "D. The Prototype pattern allows you to create customized objects without knowing their exact class details.". But doesn't the same apply to the other patterns like abstract factory and factory method also ?
In those patterns also, the client does not need to know the exact class and creation method.

Please share your thoughts on this.

Thanks
Devi
 
Ricardo Ferreira
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sreedevi Vinod:
This is another question from the Whizlabs simulator.
"Which design pattern should you use when you need to create objects without knowing either their exact class or how to create them?"

A. Abstract Factory
B. Builder
C. Factory Method
D. Prototype
E. Singleton

The answer says "D. The Prototype pattern allows you to create customized objects without knowing their exact class details.". But doesn't the same apply to the other patterns like abstract factory and factory method also ?
In those patterns also, the client does not need to know the exact class and creation method.

Please share your thoughts on this.

Thanks
Devi


The prototype objective is to create CUSTOMIZED objects. This simple sentence can disagree with the abstract factory and factory method definitions, because they are creational patterns that create objects based on an specified interface. This means that the created object will be an realization of this interface.

The prototype can create objects without know the class, but it can create any type of object, not based on a interface.

Best Regards!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic