Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 5
    Is that explanation of Factory method correct? What's about "The factory method pattern relies on inheritance, as object creation is delegated to subclasses that implement the factory method to create objects". So the example is more like Static Factory. Commented Oct 15, 2014 at 10:21
  • @SerG Well, in fairness, you've picked up that quote from Wikipedia, on a page that read very differently three years ago. I would argue that the current Wikipedia page contradicts itself in several places, but I don't have the desire to get involved in picking that apart. What I would concede, in hindsight, is that the example I've provided here is a specific kind of Factory Method, known as the Parameterized Factory Method. But the point about the difference between Factory Method and Abstract Factory holds across all types of Factory Method. Commented Oct 15, 2014 at 17:41
  • 2
    The same statement as my quote exists in GoF "Design Patterns". And Parameterized FM is also described there. Commented Oct 16, 2014 at 8:27
  • The important part is that the factory will give the caller a suitable object, depending on the particular situation, and the caller doesn't need to know what exactly the class of that object it, and doesn't need to know how the particular object was chosen, as long as the object supports an interface that the caller knows about. Commented Jul 20, 2015 at 13:48
  • You should state that clear in your answer that your example is not a typical factory method pattern, but some specialization named parameterized factory method. And write about definition of typical factory method, because it is mislading right now. I was just learning about factory method pattern, I understood everything and then I read that answer which shows factory method pattern as something different and I was confused. There is no information about that example not being typical factory method pattern. Thanks to SerG for poiniting that out in the comment. Commented Feb 28, 2017 at 15:04