• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Clarification regarding GoF - Creational Patterns

 
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am a bit confused of the difference between a Abstract Factory Pattern and Factory Method pattern.

Appreciate if any one can give me a brief clarification on the difference or point me to a place where I get a good clarification.

Thanks in advance.
 
Ranch Hand
Posts: 240
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
abstract factory (AF) : Defines an interface for creating families of objects without mention there concrete classes.

usage: 1 tablet per day. Oops. That is not for abstract factory. This is: AF encapsulates how objects are created. You don't know what implementation the AF is returning. So it is used when you want to change the objects implementation without affect clients of the object.


factory method (FM): Define an interface for creating an object, but let the subclasses decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.

usage: the concrete creation for an object O is in subclasses Sb, while the object O is probably used in the super class Sp. You use this pattern when you want to utilized inheritance and polymorphism of OO Design: The method M() that uses the created object O is in super class Sp, while the object O's creation is in sub class Sb. Client C use sub class Sb to do the work (C knows Sb) while the method M() that client is using is in super class Sp. Now, DO you understand?! If you can't, try hard, just like this:
 
Ranch Hand
Posts: 71
Hibernate Spring Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Srinivasa,

You may also check this blog entry , it explains AbstractFactoy pattern in quite a bit detail. It may be useful to you...

http://dranilev.blogspot.com/2011/02/going-technical-abstract-factory.html

Thanks!
Ranil
 
Srinivasa Kadiyala
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ranil and Bigwood
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Srinivasa,
In one line, Abstract Factory pattern is One more level of abstraction when compared to Factory Pattern.

Thanks,
Raghuram G
 
When you have exhausted all possibilities, remember this: you haven't - Edison. Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic