Factory Pattern – example
Abstract Factory Pattern – example
With the Factory pattern, you produce implementations (Apple, Banana, Cherry, etc.) of a particular interface — say, IFruit.
With the Abstract Factory pattern, you produce implementations of a particular Factory interface — e.g., IFruitFactory. Each of those knows how to create different kinds of fruit.
Creational patterns abstract the object instantiation process. They hide how objects are created and help make the overall system independent of how its objects are created and composed.
Class creational patterns focus on the use of inheritance to decide the object to be instantiated Factory Method.
Object creational patterns focus on the delegation of the instantiation to another object Abstract Factory.
The Abstract Factory Pattern
Provide an interface for creating families of related or dependent objects without specifying their concrete classes.
The Abstract Factory pattern is very similar to the Factory Method pattern. One difference between the two is that with the Abstract Factory pattern, a class delegates the responsibility of object instantiation to another object via composition whereas the Factory Method pattern uses inheritance and relies on a subclass to handle the desired object instantiation. Actually, the delegated object frequently uses factory methods to perform the instantiation!
Builder – example