Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

design patterns

 
Tayal Rohit
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the difference between factory design pattern and abstract factory design pattern, please elaborate with examples too.

thanks
 
Ellen Zhao
Ranch Hand
Posts: 581
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By using factory pattern, you are using a subclass to do object creation. Clients only see the superclass and no need to worry what is really created at run time. In abstract pattern, the abstract type creats a family of products. Compared to factory pattern, the abstract factory pattern groups a set of realted products together. You can take it this way, abstract factory pattern is bigger than factory pattern. You can often see methods of an abstract factory are implemented as factory methods.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Scroll on down to the OO, UML, Patterns, etc. forum. We had a thread on this not long ago. See ya there!
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And indeed, that's the forum in which this question belongs; I will move it there for you.
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!