aspose file tools*
The moose likes Beginning Java and the fly likes Abstract Factory Method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Abstract Factory Method" Watch "Abstract Factory Method" New topic
Author

Abstract Factory Method

Heena Joshi
Greenhorn

Joined: Sep 25, 2006
Posts: 29
Anybody can please explain me what is it and when to use it?
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
suppose you have a situation in which you have a abstract class and there are three concrete extensions of that abstract class and you want to have a class which according to a parameter will return any one of the concrete implementations.In that case factory comes into picture.Suppose i pass to the factory that i need the class with id = 1 , in that case the factory will create the object of the calss with id =1 using reflection and then return.


Rahul Bhattacharjee
LinkedIn - Blog
Heena Joshi
Greenhorn

Joined: Sep 25, 2006
Posts: 29
Thanks Rahul,

can you give me some example.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

A nonsense example, but it should be easy enough to understand
Imagine you want your favorite beer, and you're asking for it to a BeerFactory.



[My Blog]
All roads lead to JavaRanch
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Satou kurinosuke - that is a nice example.
this should be helpful.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Abstract Factory Method