File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes Clarification regarding GoF - Creational Patterns Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "Clarification regarding GoF - Creational Patterns" Watch "Clarification regarding GoF - Creational Patterns" New topic

Clarification regarding GoF - Creational Patterns

Srinivasa Kadiyala
Ranch Hand

Joined: Jun 10, 2004
Posts: 237
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.

Bigwood Liu
Ranch Hand

Joined: Feb 26, 2003
Posts: 240
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:
Ranil Liyana Arachchige
Ranch Hand

Joined: Sep 20, 2008
Posts: 71

Hi Srinivasa,

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


SCJP 1.4 (80%) , SCWCD5.0 (91%) , SCEA / OCMEA
Srinivasa Kadiyala
Ranch Hand

Joined: Jun 10, 2004
Posts: 237
Thanks Ranil and Bigwood
raghuram gannavarapu

Joined: Dec 19, 2003
Posts: 3
Hi Srinivasa,
In one line, Abstract Factory pattern is One more level of abstraction when compared to Factory Pattern.

Raghuram G
I agree. Here's the link:
subject: Clarification regarding GoF - Creational Patterns
It's not a secret anymore!