This design pattern creates an interface to create a family of interrelated objects without specifying their concrete class. It is similar to a superfactory. Its advantage is that we can add further variants, and clients will not have to worry further about the interface or actual classes for the new variants. It is helpful in supporting various platforms, windowing systems, data types, and so on. In the following example, the
Animal class is the interface that the client will know about for any animal instance.
AnimalFactory is the abstract factory that
CatFactory implement. Now, on the runtime by user input, or configuration file, or runtime environment check, we can decide whether we will have all