Back to list
Views:   0
Replies:  0
Archived
,
Reply 1
Factory : While creating object , you have to pass the concrete- product -class object from Factory.

There is no interaction between client and concrete class. Client Interacts with Factory Only. Client just calls Factory method, and in turn - factory calls respective concrete product via inheriting abstract product

Abstract Factory : While creating object , you have to pass the concrete -factory object to call Abstract Factory method, which in turn, calls  respective factory related Methods.

Again,  no interaction is there between client and concrete class.Client Interacts with Abstract Factory Only. 
Client just calls Abstract Factory method, and in turn - Abstract factory calls respective concrete product via implementing its method in concrete Factory.


Simple Rule : Abstract Factory = Factory 1 + Factory 2 + ------------Factory n , so simply , you have to pass concrete factory object to get respective factory methods , and definitely  intern class calls  methods ----  based on this factory instance. Rest is same as in factory . So this way, you get all the products of required group.
Vinod Bindal, Sep 17, 2017
Reply 2

Real Life Example. (Easy to remember)

Factory

Imagine you are constructing a house and you approach a carpenter for a door. You give the measurement for the door and your requirements, and he will construct a door for you. In this case, the carpenter is a factory of doors. Your specifications are inputs for the factory, and the door is the output or product from the factory.

Abstract Factory

Now, consider the same example of the door. You can go to a carpenter, or you can go to a plastic door shop or a PVC shop. All of them are door factories. Based on the situation, you decide what kind of factory you need to approach. This is like an Abstract Factory.

Chetan Bhujbal, May 21, 2012
Reply 3
Factory Pattern:

1. Createobject through inheritance

2. Produceonly one product

3. Implementscode in the abstract creator that make use of the concrete type that sub class produces.


Abstract Factory Pattern:

1. Createobject through composition

2. Produce families ofproducts

3. Concretefactories implements factory method to create product

Santosh Behera, Apr 05, 2012
Reply 4

Factory: A factory that creates objects that derive from a particular base class.

Abstract factory: A factory that creates other factories, and these factories in turn create objects derived from base classes. You do this because you often don't just want to create a single object (as with Factory method) - rather, you want to create a collection of related objects.

Prashant Patel, Mar 13, 2012
Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Licensing       EULA       Sitemap      
© Data & Object Factory, LLC.
Made with    in Austin, Texas