File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes OO, Patterns, UML and Refactoring and the fly likes factory and abstract factory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "factory and abstract factory" Watch "factory and abstract factory" New topic
Author

factory and abstract factory

Dave Chawan
Greenhorn

Joined: Jun 29, 2006
Posts: 7
What is the difference between factory and abstract facory (or idea behind factory vs abstract factory)?

Thanks,
Dave
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Have a look at the following discussions:
Builder Pattern Question
abstract and abstract factory
Abstract Factory vs Factory pattern
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
I'll assume by factory you mean Factory Method. A Factory Method can return different concrete types based on any kind of internal logic. I use them to get the proper strategy based on a product type:

That will give me some variety of pricing strategy for a toaster. I might get a different one for a blender. PricingStrategy is probably an interface here.

Abstract factory gets you a whole factory again based on some logic. The factory creates a family of related things. Different factory implementations give you different families. They might use more Factory Methods or just plain creator methods.


I think these patterns are poorly named and fussy in their definitions. I might even have gotten some of the details wrong because I don't strive to adhere to them perfectly. Ilja will let us know.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Dave Chawan
Greenhorn

Joined: Jun 29, 2006
Posts: 7
Thanks guys for clarifying this.

I really appreciate it.

Dave
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: factory and abstract factory