American horizo wrote:What's the difference between FACTORY and ABSTRACT FACTORY methods?
I think that the first confusion here is with the design pattern names: you are reading up on the Factory Method pattern and the Abstract Factory pattern. While saying "factory method" for the former is also correct, "abstract factory method" for the latter is potentially confusing.
Consider the intent of each of the design patterns as described by the GoF:
Factory Method: Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.
Abstract Factory: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.
Great. This means that in both cases at least one abstract base class is involved, so using "there's an abstract base class!" as a rule of thumb to determine if the design pattern is Abstract Factory does not work. (EDIT: well, it is not actually true that an abstract base class will always be involved for the Factory Method pattern since a factory method could return an object of a concrete base class, and the base class declaring the factory method could be a concrete class with a reasonable default implementation of the factory method. However, my point stands since an abstract base class can be involved.)
American horizo wrote:To me it seems that they are both abstract factories
Your factory.png diagram does indeed provide an example of the Factory Method pattern: the CommsManager class defines an interface for creating an object (i.e., getApptEncoder is the interface, ApptEncoder is the supertype of the object created), but it lets subclasses (MegaCommsManager and BlogCommsManager) decide which class to instantiate (i.e., by overriding getApptEncoder to instantiate a MEGAApptEncoder object and a BlogsApptEncoder object, respectively).
(EDIT: I originally wrote a "no" at the start of my previous paragraph, but I think it is not accurate: the diagram can indeed be used to represent an abstract factory. The thing is, these UML class diagrams aid in understanding, but do not describe the design patterns by themselves. Thus, insisting that a diagram used to help describe the factory method pattern actually describes the abstract factory pattern is missing the point.)
Your 99.jpg diagram does indeed provide an example of the Abstract Factory pattern: the CommsManager class provides an interface (collectively: getApptEncoder, getTtdEncoder and getContactEncoder) for creating families (ApptEncoder, TtdEncoder, ContactEncoder) of related or dependent objects without specifying their concrete classes.
It looks like the diagram for Abstract Factory is basically an expanded version of Factory Method, and indeed the GoF remark that "AbstractFactory classes are often implemented with factory methods", though they also note that "they can also be implemented using Prototype".