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..

Jignesh TrivediPosted Sep 23, 2013, 12:22 AM
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.
Sanjeeb LenkaPosted Sep 22, 2013, 2:05 PM
http://www.c-sharpcorner.com/UploadFile/SukeshMarla/learn-design-pattern-abstract-factory-pattern/
Jasminder SinghPosted Sep 22, 2013, 1:13 AM
http://dotnetfreakblog.wordpress.com/2013/09/22/abstract-factory-pattern-using-c/