Hi,
what is the difference between factory and abstract factory method?
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Apr 4, 2012, 2:08 AM EDT
http://stackoverflow.com/questions/6409926/factory-vs-abstract-factory-design-pattern
SenthilkumarRank #387 · 6.5K reputationPosted Apr 4, 2012, 2:48 AM EDT
Difference between factory and abstract factory:
http://c2.com/cgi/wiki?AbstractFactoryVsFactoryMethod
http://objectmix.com/object/10922-difference-between-factory-abstract-factory.html
If you want to know all the patterns then
http://www.dofactory.com/Patterns/Patterns.aspx
Jignesh TrivediRank #16 · 50.3K reputationPosted Apr 4, 2012, 11:43 PM EDT
Factory
Define an interface for creating an object but let subclasses decide which class to instantiate.
This means that an abstract Creator class defines an abstract create method (or provides a default create method) which returns an abstract Product.
A ConcreteCreator class implements the abstract create method to return a ConcreteProduct. This enables the Creator to defer Product creation to a subclass.
Factory Method is often used in the Abstract Factory pattern to implement the create methods
Pros
* shields clients from concrete classes
*the Creator create method can be coded to return a default Product
cons
* coding a new Product means writing two classes
* one for the concrete Product and one for the concrete Creator
* static
* inheritance based
Abstract Factory:
Provide an interface for creating families of related or dependent objects without specifying their concrete classes
This means that a family of abstract create methods are grouped in an AbstractFactory interface.
ConcreteFactory implementations implement the abstract create methods to
produce ConcreteProducts.
Pros.
* shields clients from concrete classes
* easy to switch product family at runtime
* just change concrete factory
* keep it in the family
* enforces product family grouping
Cons.
* adding a new product means changing factory interface + all concrete actories
hope this help.