Creating objects from different families using the abstract factory pattern
This pattern introduces a factory abstraction without the requirement to define specific classes (or classes that should be instantiated). The client requests a proper factory that instantiates the object instead of attempting to create it. The abstract factory pattern was mentioned in the GoF’s book.
Motivation
Modularizing applications can become a challenge. Software designers can avoid adding code to classes to preserve encapsulation. The motivation is to separate the factory logic from the application code so that it can supply the appropriate factory to produce the required objects. An abstract factory provides a standardized way to create an instance of the desired factory and deliver that instance to the client for use. The client uses the resulting factory to instantiate the object. Abstract factory provides an interface for creating both factories and objects without specifying their...