Factory Method

E173604

Factory Method is a creational design pattern that defines an interface for creating objects while allowing subclasses to decide which concrete classes to instantiate, promoting loose coupling and extensibility.

Try in SPARQL Jump to: Surface forms Statements Referenced by

All labels observed (3)

Statements (49)

Predicate Object
instanceOf creational design pattern
design pattern
object-oriented design pattern
advantage makes it easy to introduce new product types without changing client code
simplifies code that uses products by hiding instantiation details
allows subclasses to override the factory method
alsoKnownAs Factory Method
surface form: Factory Method Pattern

Virtual Constructor
applicableWhen a class cannot anticipate the class of objects it must create
a class wants its subclasses to specify the objects it creates
classes delegate responsibility to one of several helper subclasses and want to localize the knowledge of which helper subclass is the delegate
belongsToCategory Design Patterns: Elements of Reusable Object-Oriented Software
surface form: Gang of Four design patterns

creational patterns
commonImplementationLanguage C#
C++
Java
JavaScript
Python
definedIn Design Patterns: Elements of Reusable Object-Oriented Software
defines factory method operation in the Creator class
describedBy Gang of Four
differsFrom Abstract Factory pattern by creating one product at a time instead of families of products
disadvantage adds indirection to object creation
can lead to a proliferation of subclasses
encourages programming to an interface rather than an implementation
hasIntent define an interface for creating an object but let subclasses decide which class to instantiate
promotes extensibility
loose coupling
open-closed principle
single responsibility principle
reduces direct dependency on concrete classes
relatedTo Abstract Factory
surface form: Abstract Factory pattern

Strategy pattern
Template Method
surface form: Template Method pattern
separates product creation from product usage
structureIncludes ConcreteCreator
ConcreteProduct
Creator
Product
typicalParticipants abstract creator class with factory method
concrete creator classes implementing factory method
concrete product classes
product interface or abstract class
typicalUseCase UI libraries that create platform-specific widgets
frameworks that let users extend and provide custom products
logging libraries that create different logger implementations
usedFor deferring instantiation to subclasses
encapsulating object creation
selecting concrete implementations at runtime

Referenced by (8)

Full triples — surface form annotated when it differs from this entity's canonical label.

Factory Method alsoKnownAs Factory Method
this entity surface form: Factory Method Pattern
Abstract Factory relatedTo Factory Method
Abstract Factory oftenImplementedWith Factory Method
Builder relatedTo Factory Method
this entity surface form: Factory Method pattern
Prototype relatedTo Factory Method
Flyweight oftenUsedWith Factory Method
this entity surface form: Factory Method pattern
Template Method relatedTo Factory Method
this entity surface form: Factory Method pattern