The benefit of this is if in the future the implementation of the object that implements the interface changes, the consuming client is not affected as long as the interface remains the same.
An Abstract Factory class is a class which exist to create instances of another class.
If you want to create an instance of class at runtime (Means class should be selected at runtime).
1) Create an AbstractFactory class for each class you wish to create.
2) In each AbstractFactory class there should have a polymorphic “created instance” method, conforming to a method signature, used to create instances of the corresponding classes.
Suppose an Abstact class wants to hide its subclass name and instantiation.
abstract class BaseClass
static BaseClass GetInstance()
return new ChildClass();
class ChildClass extends BaseClass
BaseClass objBase = BaseClass.GetInstance();