Get everything here:
Best Design Patterns Book :
Welcome to my Factory design pattern tutorial. This is a continuation of my design patterns video tutorial.
You use the Factory design pattern when you want to define the class of an object at runtime. It also allows you to encapsulate object creation so that you can keep all object creation code in one place.
The Factory pattern is presented in many ways to help you learn. Refer to the code to completely understand it.