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
Information Retrieval from Multi-Agent System with Data Mining in Cloud Computing Project Description: I have planned one research model on "Information Retrieval through Mul

What do you understand by SOAP encoding? The Serialization of the types, such as integers and strings, inside a SOAP message is known as encoding. The SOAP objects use XML elem

What is Manual Reset Event and Auto Reset Event? The Threads that call one of the wait methods of a synchronization event should wait until other thread signals the event by ca

Avoid deadlock in threading The best  and careful planning may avoid deadlocks.There are so many ways Microsoft has provided by which you can decrease deadlocks for example Int

how do you do dot net programming

Add in bitcoin payment option in website Project Description: Include bitcoin files to magento for payment options on website. It is just including the files to the magent

how to replace a keyword using powershell

The Full form of CLR is Common Language Runtime and it is  the heart of the .NET framework. All Languages have its own runtime and its the responsibility of the runtime to take car

What is the difference between Authentication and authorization? This is  a tricky question. These two concepts seem altogether same  but there is big  difference. The Authenti

I want to prepare one web based application which have student registration and according to semester and every time it will change as per semester change according, now student ge