When to use Factory method pattern?

Viewed 31347

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?

10 Answers

I think its when you want your application to be loosely coupled and extensible in future without coding changes.

I have written a post on blog as to why i choose the factory pattern in my project and may be it can give you more insight. The example is in PHP but i think its applicable in general to all languages.

http://www.mixedwaves.com/2009/02/implementing-factory-design-pattern/

Related