Factory Method Pattern Structure
The Factory Method Pattern involves four key participants. First, the Product interface defines the interface of objects the factory method creates. Second, ConcreteProduct classes implement the Product interface. Third, the Creator declares the factory method that returns a Product object. Fourth, ConcreteCreator classes override the factory method to return specific ConcreteProduct instances.
+ someOperation(): void
First, ConcreteProduct classes implement the Product interface (▲ inheritance/implementation). Second, ConcreteCreator classes extend the Creator class (▲ inheritance). Third, Creator depends on the Product interface but not on concrete products. Fourth, each ConcreteCreator creates a specific ConcreteProduct.
The factoryMethod() is abstract or returns a default Product. The someOperation() in Creator uses the product returned by factoryMethod() but does not know the concrete type. ConcreteCreators override factoryMethod() to return specific ConcreteProduct instances.