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
What is fill factor? The 'fill factor' option describes how full SQL Server will make each index page. When there is no free space to insert a new row on the index page, the SQ

I want to develop SMS application with auto reply based on the content of the message using gsm modem. eg.Student results checking using cell phone via sms. How do i do this?

They are triggered in the following order as shown below: Application_BeginRequest Application_AuthenticateRequest Application_AuthorizeRequest Application_ResolveReque

Differentiate between Boxing and Unboxing. When a value type is changed to an object type, the process is known as boxing; while, when an object type is changed to a value type

I need very easy project in metatrader Project Description: I have 3 indicators.... ADX, emas crossover and macd crossover! They are all signals, arrows! But i would like to

I need a Windows SharePoint Services or Similar Solution My company desires a reliable way of managing the documents online for each of its clients. The solution would want t

Project Description: i will testing some software which you need and i promise to do my job is the best way, and as fast as possible. Skills required: .NET, MySQL, C# P

I want a C# school project Project Description: The project is made in C# and haves a database connection. We have some small problems asking up data from the database.

What is PLINQ? PLINQ stands for Parallel Language Integrated Query. It is the parallel execution of LINQ, in which a query can be implemented by using multiple processors. PLIN

How can you implement a condition in a workflow? You can implement a condition by using either of the following ways: By creating a rule condition - Specifies that you can e