Uses of abstract factory design pattern [Resolved]

Posted by raghuavulapalli-25110 under Best Practices on 1/20/2014 | Points: 10 | Views : 2138 | Status : [Member] | Replies : 1
Hi,

when and in which scenario abstract factory design pattern and how it is different from factory design pattern? what are its advantages? please explain with real world example..

Thanks,

Raghunath


Responses

Posted by: kgovindarao523-21772 on: 1/20/2014 [Member] [MVP] Bronze | Points: 50

Up
0
Down

Resolved
Hi,



A real life example for the use of the Abstract Factory pattern is providing data access to two different data sources (e.g. a SQL Database and a XML file). You have two different data access classes (a gateway to the datastore). Both inherit from a base class that defines the common methods to be implemented (e.g. Load, Save, Delete).

Which data source shall be used shouldn't change the way client code retrieves it's data access class. Your Abstract Factory knows which data source shall be used and returns an appropriate instance on request. The factory returns this instance as the base class type.


Thank you,
Govind

raghuavulapalli-25110, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response