Could anyone help me to understand the the following queries regarding factory method pattern?
im refering this link as a sample.
1.what is the need of abstract class in factory method pattern? What if use a normal class?
2.It is stated that change in the code will not affect the client.But if A new class product3 has been added, an appropriate change will be required in the client code also.(as per the below code). Then what is the advantage of this design pattern?
3.What is the benefit of objFactories[0] = new concreteFactoryforProduct1();
over concreteFactoryforProduct1 factory = new concreteFactoryforProduct1();
Factory[] objFactories = new Factory[2];
objFactories[0] = new concreteFactoryforProduct1();
objFactories[1] = new concreteFactoryforProduct2();
foreach (Factory objFactory in objFactories)
{
Product objProduct = objFactory.GetProduct();
objProduct.GetDetails();
}
4.Why we cant implement open close principle in simple design pattern?
Aucun commentaire:
Enregistrer un commentaire