3

During a recent phone screen I was asked to describe the "Factory Pattern". I asked if the screener meant "Factory Method" or "Abstract Factory". He said, "No, just the Factory Pattern".

I don't know what the Factory Pattern is except in the context of the aforementioned GoF patterns. I've been researching this since the phone screen, but nothing I've found indicates that there is a third "just" Factory Pattern. The closest I came was this question, but still that seems to just distinguish Factory Method from Abstract Factory.

Is there a distinct third factory design pattern? If not, does "Factory Pattern" always just mean "Factory Method"?

  • 2
    This Wikipedia page is very detailed about all the different terms containing the word "Factory" and how they are used. – Doc Brown Nov 30 '15 at 18:32
  • Someone mentioned the Factory Pattern to me too and even provided what was a wiki page en.wikipedia.org/wiki/Factory_(design_pattern). I never heard of it and I guess someone realised this mistake and now that page is just a redirect to Factory (object-oriented programming) page. – imel96 Dec 1 '15 at 1:11
5

To the best of my knowledge, no design pattern library discusses anything called a "factory pattern". There is a general term "factory", which simply refers to an object that creates other objects. But if you're talking about the documented names for patterns, you need to be specific - after all, part of the point of design patterns is for communication, so everyone should be using the same terms.

Some sites do discuss different types of specific factories, such as Abstract Factory and Factory Method together. OODesign.com does this, and C2 wiki has a page called "FactoryPattern" that links to the pages for Abstract Factory and Factory Method.

2

Factory pattern refers to the general principle of having an entity (be it a class, an abstract class, an interface or a method) which knows how to create instances of other entities (usually objects implementing an interface of interest) on behalf of a caller so that the caller does not have to know how to create them.

Both abstract factories and factory methods are specializations of the factory pattern. So, I think the interviewer was a bit of a stickler. Or perhaps they failed to communicate to you that all they wanted from you was to describe the general principle, not caring about any specifics. Or perhaps they were suspicious as to whether you understand the general principle and you have not just memorized the definitions of certain terms.

  • Or the interviewer didn't have the best understanding of the pattern(s) himself. – Roman Reiner Dec 1 '15 at 6:14
  • @RomanReiner you are right; that, too. C-:= – Mike Nakis Dec 1 '15 at 18:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.