I am learning about design patterns and the first example in the book is about Abstract Factory. I have built the exercise in VS and all looks good, but there is one question that I wonder about.
In the book the factory class is implemented like this:
public abstract class AbstractVehicleFactory
{
public abstract IBody CreateBody();
public abstract IChassis CreateChassis();
public abstract IGlassware CreateGlassware();
}
After completing the exercise I have noted that the above class can be replaced with this code:
public interface IAbstractVehicleFactory
{
IBody CreateBody();
IChassis CreateChassis();
IGlassware CreateGlassware();
}
Of course both examples function exactly the same, but I wonder what is the reason for using an abstract class and not an interface?