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 SCEA Part  -I - Questions out desgin pattern Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "SCEA Part  -I - Questions out desgin pattern" Watch "SCEA Part  -I - Questions out desgin pattern" New topic

SCEA Part -I - Questions out desgin pattern

Apratim Khandalkar
Ranch Hand

Joined: Jan 09, 2006
Posts: 34
I am not able to understand the exact differance between factory pattern and abstract factory patttern . I know the difference theoratically but in which situations exactly which pattern to use is not clear.
Can somebody explain how to decide if the factory pattern is used or abstract factory pattern is to be used.
Ranch Hand

Joined: Aug 18, 2005
Posts: 372
Here is one main difference between the 2 patterns :

1. Use the Factory Method pattern when you are creating just one object and you want to encapsulate the object creation. Basically, you feel that the object creation is an area of change as newer concrete classes could get added later on and hence you want to encapsulate that area of change

2. Use the abstract factory pattern when you want to create a family of dependent objects related to each other in some way. Even for creating one object, you could use the Abstract factory, but that would be overkill. Generally, the factory method using inheritance provides better performance than the AF which uses composition.

Hey, post this question in the OO and patterns forum. We can expect a nice answer from Ilja Preuss. Even I would like to read her answer for this.
Apratim Khandalkar
Ranch Hand

Joined: Jan 09, 2006
Posts: 34
Hey Sathish ,
Thanks a lot that was preety well explained.I will surely post thid topic on oo and pattern forum as well.
I agree. Here's the link:
subject: SCEA Part -I - Questions out desgin pattern
It's not a secret anymore!