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
Question: (a) Write extract codes to show the structure of the Global.asax file. (b) Outline four classes that allow you to work with File Streams. (c) When working with

Briefly explain the characteristics of reference-type variables that are supported in the C# programming language. The variables that are based on reference types keeps referen

What is basic use of "DataView"? The "DataView" represents the whole table or can be small parts of rows depending on some criteria. It is the best used for sorting and finding

ASP Programmer I need a fixing all W3c validation errors and it is a ASP website. Have any queries please send a message and I will provide more information on project. De

Requirements: 1.  Complete the following two exercises by developing working csharp projects. 2.  Write a report to explain csharp code written in the projects. 3.  Submi

What is an XMLReader Class? This is an abstract class available from the System.XML namespace. The XML reader works on a read-only stream browsing from one node to another in a

Question: (a) List the two main advantages of developing a Multitiered Web Applications. (b) Explain how Validation controls are used to validate forms. (c) Using com

What is a Metadata?  Metadata is information about a PE. In COM, metadata is communicated through non-standardized type libraries. In .NET, this data is contained in the header

C# API to grab option price from CBOE web site Project Description: On the web page below, user will download option prices of Stock or Index. For example, if you put "VXX" i

What is a static constructor? Static constructors are introduced with C# to initialize the static data of a class. CLR calls the static constructor before the initial instance