Bookmark Topic Watch 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
The basic difference between FactoryMethod and AbstractFactory is that the FactoryMethod is called from inside the class hierarchy (the abstract base class), whereas the AbstractFactory is used from the outside. (The GoFBook tries to hint at this fact by saying that FactoryMethod is "class based", whereas AbstractFactory is "object based".)

This is very similar to how TemplateMethod and the StrategyPattern work. In fact you could say that FactoryMethod is a specialized TemplateMethod, and AbstractFactory is a specialization of the StrategyPattern.

Often TemplateMethod gets confused with what is often called a SimpleFactory or just Factory - a class with a static method that creates an object. The book RefactoringToPatterns coined the less confusing term CreationMethod for this pattern.

E.g:



=============





Other resources:


  • Wiki:AbstractFactoryVsFactoryMethod

  •  
    Evacuate the building! Here, take this tiny ad with you:
    a bit of art, as a gift, that will fit in a stocking
    https://gardener-gift.com
      Bookmark Topic Watch Topic
    • New Topic