When to use Factory method pattern?
Please provide me some specific idea when to use it in project? and how it is a better way over new keyword?
I have two cases where I tend to use it:
Examples:
First case could be that you want to have a factory creating SqlCommand objects, where you automatically attach a valid SqlConnection before returning the command object.
Second case is if you have an interface defined and determine at execution time which exact implementation of the interface to use (for instance by specifying it in a configuration file).