• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SCEA Part -I - Questions out desgin pattern

 
Apratim Khandalkar
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Thanks
 
B.Sathish
Ranch Hand
Posts: 372
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Sathish ,
Thanks a lot that was preety well explained.I will surely post thid topic on oo and pattern forum as well.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic