Simple Factory vs Factory Method pattern
Fast recall
Quick revision
Core answer
Interview-ready guide
Interview answer
A Simple Factory is a common name for one function or object that chooses and creates a product, often with a switch or a registry. It is useful but is not one of the named GoF patterns. Factory Method is the GoF pattern where a creator defines a creation method and subclasses override which product it returns, often while the parent owns a larger workflow. The trade-off is central selection versus a creator class hierarchy. I would not say a simple factory always violates Open/Closed or Factory Method guarantees it: a registry can extend a simple factory, and some code still chooses the concrete creator. I select the simplest mechanism for the expected change.
Simple Factory vs Factory Method pattern
Direct Answer
A Simple Factory is a common name for a function or object that selects and creates products, often from a switch or registry; it is not one of the named GoF patterns. Factory Method is the GoF pattern in which a creator defines a creation method and subclasses can override which product it supplies. Neither form automatically satisfies the Open/Closed Principle: selection, registration, and client construction still need design.
Common Mistakes & Pitfalls
- Calling Simple Factory a GoF pattern. It isn't — it's a precursor idiom the book only mentions.
- Missing the OCP violation. Every new type edits the Simple Factory switch; Factory Method avoids that with subclasses.
- Over-applying Factory Method. For a small stable type set, a static helper is fine; inheritance is overkill.
- Thinking they're unrelated. Simple Factory is usually the first step you later refactor into Factory Method.
Check your understanding
Answer these without looking back at the article.
- What is Abstract Factory pattern?
- When would you prefer Factory Method over Simple Factory?
- Why does Simple Factory violate the Open/Closed Principle?
Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.