How can I force the usage of Factory. The factory method design pattern handles these problems by defining a separate method for creating the objects. We can start thinking that what could be our parent class. It is used to create a set of related objects, or. Code sample (with factory inside the business object class) One way to create a factory is to add a static method to the class we want to instantiate.
I have asked a question that why we have to use abstract method in public abstract Car.