Difference between factory and abstract factory patterns, DOT NET Programming

What is the difference between Factory and Abstract Factory Patterns?

The main basic difference between factory and Abstract factory is factory method uses the  inheritance to decide which object has to be instantiated while the abstract factory uses the delegation to decide the instantiation of the object. We can say that Abstract factory uses factory method to done  the architecture. The Abstract Factory is one level greater  in abstraction over the Factory.

The 2  class figure  below will provide the overview of what is the actual difference. First figure shows a sample  of the implementation of the Factory Patterns. In this figure there are2  basic sections:-

1)The actual product section that  is  Class "Product" it inherits from an abstract class "AbstractProduct".

2)The creational aspect part that is . "ConcreteCreator" class which inherits from class "Creator".

3)Now there are various rules that the client will have to follow who will require the "Product" object. He will never suggest directly to the actual "Product" object he will suggest  the "Product" object by using the "AbstractProduct".

4)The Second client will never use the "New" keyword to create the "Product" object but will use "Creator" class which in turn will use "ConcreteCreator" class to create a  actual "Product" object.

502_factory pattern.png

Figure: - Class diagram of a factory Pattern

Now let's look at the second class diagram that provides an overview of what actually the "Abstract factory" pattern is. It creates objects for families of the classes. In brief it describes the collection of factor methods from different families. In brief it groups related to factory methods. For e.g.  in this the class "Creator" is implemented by using the "Abstract" factory pattern. It then  creates objects from the multiple families rather than one product.

2080_factory pattern1.png

Figure:-Class Diagram of Abstract Factory

Posted Date: 9/22/2012 6:16:04 AM | Location : United States







Related Discussions:- Difference between factory and abstract factory patterns, Assignment Help, Ask Question on Difference between factory and abstract factory patterns, Get Answer, Expert's Help, Difference between factory and abstract factory patterns Discussions

Write discussion on Difference between factory and abstract factory patterns
Your posts are moderated
Related Questions
Custom Mql4 Code/Fxdreema block Project Description: I need the subsequent code written in mql4 and integrated as custom block(s) in fxdreema: for each trade: check pro

What are the precautions so that StateServer Mode work properly? Following are some points to remember so that StateServer Mode works properly:- a) StateServer mode session

Audio Expert in C# Required - Generate Audio Engine, Exciting Project! Project Description: We need an EXPERT CODER to help us create an 'audio engine' in C#. We need to b

Webservices as such do not have any mechanism by which they can maintain their state. The Webservices can access ASP.NET intrinsic objects such as application, session and many mor

Ask question #Minimum 100 words accepWrite an ASP.NET program that allows you to create and populate a CheckBoxList control by accessing the Title field from the Movies database ta

CRM and Shaerpoint We are using 365+ CRM in the cloud for QuattroCitta at the moment which we will migrate to our own private cloud in six months (project part 2). Within ShareP

The costumer is an application that tracks production costuming, structure and other related pieces. We discussed this in detail and you have commentary and video to define the pro

What is a Class in dot Net? The class describes all the attributes of objects, as well as the methods which implement the behavior of member objects. It is a comprehensive data

Describe the rules and regulations that must be followed whereas creating a well-formed XML document. The following are the rules and regulations that are essential to follow w

NameSpace Namespace consists of 2  main basic functionality :- NameSpace Logically types group , ex. System.Web.UI logically groups our UI related features. In Object O