1. Factory mode: Defines a set of interfaces for creating objects, but subclasses decide which class to instantiate. The factory method defers the instantiation of the class to the subclass.
Now consider that there are pizzastore (franchisees), they may have some improvements to the pizza approach, that is, the Createpizza method needs to be upgraded. The approach of the factory method is to create a method in the base class that is shaped as abstract Product FactoryMethod (String type), which, as a factory method, is responsible for creating the object, which can be overridden by the subclass to alter the process of creating the object.
The subclass returns an object of type pizza, which can be used uniformly by the parent class without concern for the specific type
2. Abstract Factory mode: Provides an interface for creating an object family without specifying a specific class.
Factory methods only involve the creation of an object, sometimes we need a family of objects, such as the example in the book: The raw Material family. Making pizza requires a lot of raw materials, each of which requires a factory approach. At this point we set all the methods involved in creating objects together as an interface. The user is programmed for this interface, and the interface is implemented by a specific class. This way we can pass the corresponding class that implements this interface to the consumer, depending on the situation.
Factory mode and abstract Factory mode