mercredi 22 juillet 2015

Abstract Factory method practice or usage of abstract factory pattern in an API

First of all sorry as I may sound quite stupid while asking this.

I want to understand the practical usage of abstract design pattern. Which all APIs have implemented this pattern and under what all use case.

One of the use case which strikes me immediately is the DI of objects which need to be created using run time information.

I have the understanding that this pattern is used to create object of various product families. But for every new product family we have to change the existing factories. Also if there is an addition implementation of any product family we have to provide a new factory for this new implementation.

For example

I have products Frame and TextBox for two types of OS ( Windows and MAC). Now we will have two factories one for each Window and Mac so that WindowFactory returns textbox and frame for Windows and MacFactory return the same objects for MAC. Now say I want to add another OS say Solar then in this case I need to write a new factory which returns the corresponding objects for solar.

How API use this patterns in real world?

Aucun commentaire:

Enregistrer un commentaire