• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Abstract Factor / Factory Method / Factory

 
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys,
Let me if the one liners below are correct and why Factory as such is not in the 23 GOF Patterns, though its there in the Java Design Pattern book by cooper.
Abstract Factory: helps creating objects for family of simillar objects.
Factory Method: the object creation is deferred to the sub class.
Factory: Object creation by another class.
rgds
 
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it should have been Factory method design pattern
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looks good. There is a nice example of abstract factory in another post from a few days ago. I frankly did not get the distinctions from the GoF book ... it took a few examples to get it.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Stan James:
There is a nice example of abstract factory in another post from a few days ago.


Mhh, couldn't find it. Do you have a link, please?
 
Stan James
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yknow, I couldn't find it either. A common example is a factory for GUI widgets. Say you had one factory per Look&Feel style. If you bought a new style it would come with a factory. That concrete factory would have to implement an interface or extend an abstract factory. All factory implementations would have getButton, getText, getMenuItem, etc. hope that made sense!
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, that made sense.
So, what do you think *is* the difference between Factory Method and Abstract Factory? (We just had this discussion at our Design Patterns Workshop, so I am very interested in everyones opinions...)
 
Stan James
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I thought this was poorly covered in GoF. Meaning I was too dense to get it the first ten times through.
Factory methods can be useful even with a concrete final factory. I guess a class could have "factory methods" even if its primary function in life was something other than a factory, tho you don't want to blow SRP with too many jobs. Anything that does "get me the right class for this parameter because I don't know ahead of time" is doing a factory method thing.
Abstract factory took me longer. Examples like the UI widgets and others help a lot.
We had a consultant who wrote a FactoryFactory to get a Factory to get an object and there was only one possible class for the object. He must have REALLY loved that chapter in GoF!!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic