6

What is this factory all about and what are the advantages of using factory patterns? Does it give a plugable architecture? Why it is called "Factory"?

RKh
  • 13,080
  • 40
  • 145
  • 251

2 Answers2

5

It is factory since it is actually "Manufacturing" (Create) an object.

There's actually two kind of factory pattern defined by GoF:

  1. Factory Method
  2. Abstract Factory

Basically both of them tries to decouple the calling client from knowing the actual concrete implementation of the class/interface.

xandy
  • 27,069
  • 8
  • 58
  • 64
  • So this would be useful if you needed to account for the possibility that your model (in MVC) might change? Is there anything undesirable about creating a model in your application that is dynamic depending on the circumstances ? I'm guessing one downside is the added complexity of making sure that any permutations don't break your views or your controllers. – stonybrooklyn Jul 26 '17 at 16:10
3

You can find all you need by reading this PDF article

Adnan
  • 24,852
  • 17
  • 77
  • 108