The Abstract Factory pattern creates families of related products through a single factory interface, while the Factory pattern (Factory Method) focuses on creating just one type of product, typically deferring the exact class choice to a subclass.
Key Points: • Abstract Factory groups multiple related creation methods behind one factory interface; Factory Method has a single creation method. • Abstract Factory guarantees the products it returns are compatible with each other since they share a concrete factory. • Factory Method is often used internally as a building block inside an Abstract Factory implementation. • Abstract Factory involves a family of concrete factory classes; Factory Method usually involves a creator class hierarchy. • Choose Factory Method for single-product creation and Abstract Factory when multiple related products must be created together consistently.
Example: A Factory Method might just produce a single Button given a type, while an Abstract Factory for a UI theme would produce a matching Button, Checkbox, and Menu together so the whole interface follows one consistent visual theme.
Interview Tip: A concise interview answer is:
"Abstract Factory creates families of related objects through one factory interface and guarantees they're compatible with each other, while Factory Method is scoped to creating a single product and deferring the concrete class choice to a subclass — Abstract Factory is often built out of several Factory Methods internally."