Hi all, was exploring the abstract factory pattern and in every second article, i get this definition :
"an interface is responsible for creating a set of related objects, or dependent objects without specifying their concrete classes."
I ?created a sample code based on my understanding of this pattern and ideas that came from other articles. But there are certain points that are still confusing me :
1. What does the definition mentioned above means ?
2. Why would i need to have an abstract factory pattern ?
I was able to create a sample code, but I am not sure what part of the code/implementation is must to go for an abstract factory pattern. My sample code is :
///
/// Master 'Abstract Factory'
///
public interface IMasterFactory
{
IProduct1 Getproduct1();
Iproduct2 GetProduct2();
}
///
/// Abstract Product 1
///
public interface IProduct1
{
String GetProduct1Type();
}
///
/// Abstract Product 2
///
public interface IProduct2
{
String GetProduct2Type();
}
public class ManufacturerA : IMasterFactory
{
public IProduct2 GetProduct2Type()
{
return new Product2Type();
}
public IProduct1 IProduct1Type()
{
return new Product1Type();
}
}
public class Product1Type: IProduct1Type
{
public string GetProduct1Type()
{
return "Product 1 Type";
}
}
public class Product2Type: IProduct2Type
{
public string GetProduct2Type()
{
return "Product 2 Type";
}
}Which code i can remove from here to say that it was not required to be written..


Jasminder SinghRank #210 · 11.6K reputationPosted Sep 21, 2013, 9:13 PM EDT
http://dotnetfreakblog.wordpress.com/2013/09/22/abstract-factory-pattern-using-c/
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Sep 22, 2013, 10:05 AM EDT
http://www.c-sharpcorner.com/UploadFile/SukeshMarla/learn-design-pattern-abstract-factory-pattern/
Jignesh TrivediRank #16 · 50.3K reputationPosted Sep 22, 2013, 8:22 PM EDT
hi,
Abstract factory pattern is useful when the client needs to create objects which are somehow related.
Please refer
http://www.codeproject.com/Articles/328373/Understanding-and-Implementing-Abstract-Factory-Pa
http://www.dotnet-tricks.com/Tutorial/designpatterns/4EJN020613-Abstract-Factory-Design-Pattern---C
hope this will help you.