What is Abstract Factory pattern and what is it for? According to Design Patterns by GoF, the intent of Abstract Factory is to,
Provide an interface for creating families of related or dependent objects without specifying their concrete classes.
Abstract Factory conforms to the principle of "program to an interface, not an implementation." In Abstract Factory pattern, the class that is responsible for creating concrete objects (Products) is said to be a Factory class. In order to create different types of concrete Products, different type of concrete Factory classes will be used. Each Factory is just a collection of factory methods (e.g. CreateProductA(), CreateProductB()). Each factory method creates a concrete Product of the same family.
The client code's factory method creates the final product based on a given factory. This extra layer of abstraction is provided to the client code by introducing the concept of factory. This is the most common way to implement the Abstract Factory pattern.
 A factory method that creates an empty maze to begin with, not a final end product.
 Because each Factory knows how to make the product of their own family. The client code (MazeGame) simply has a factory method which depends on an abstract factory to create the final end Product - a final version of Maze. As demonstrated above, the Factory class adds an layer of abstraction to the client without exposing the implementation details of the products.
Another good example of an Abstract Factory in use could be UI toolkits across Windows, Mac and Linux, UI composites such as windows, buttons as described on DZone.
Use Abstract Factory patter when you want to:
Abstract Factory vs Builder:
They are quite similar with the following differences:
Abstract Factory vs. Factory Method