G
Guest
I am using the factory method to solve a problem where a factory can produce
product.
I have a base factory class and a base product class. The problem that I am
having is that for every product subclass type I am having to create a
factory subclass to handle differences in logic. They are becoming one to
one. Is this ok? Should I look at another pattern to solve the problem?
abstract Product
Product1: inherits Product
Product2: inherits Product
abstract Factory
Factory1: inherits Factory
Factory2: inherits Factory
abstract class Factory
{
public Product Generate()
{
throw new System.NotImplementedException();
}
}
public class Factory1: Factory
{
}
public class Factory2 : Factory
{
}
abstract class Product
{
}
public class Product1: Product
{
}
public class Product2 : Product
{
}
product.
I have a base factory class and a base product class. The problem that I am
having is that for every product subclass type I am having to create a
factory subclass to handle differences in logic. They are becoming one to
one. Is this ok? Should I look at another pattern to solve the problem?
abstract Product
Product1: inherits Product
Product2: inherits Product
abstract Factory
Factory1: inherits Factory
Factory2: inherits Factory
abstract class Factory
{
public Product Generate()
{
throw new System.NotImplementedException();
}
}
public class Factory1: Factory
{
}
public class Factory2 : Factory
{
}
abstract class Product
{
}
public class Product1: Product
{
}
public class Product2 : Product
{
}