File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

factory and abstract factory

 
Dave Chawan
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the difference between factory and abstract facory (or idea behind factory vs abstract factory)?

Thanks,
Dave
 
Peer Reynders
Bartender
Posts: 2938
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8791
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Dave Chawan
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys for clarifying this.

I really appreciate it.

Dave
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic