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.

All labels observed (5)

How this entity was disambiguated

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 Pattern ⓘ
linked to: Factory Method

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 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 pattern ⓘ
linked to: Abstract Factory

Strategy pattern ⓘ
Template Method pattern ⓘ
linked to: Template Method
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 ⓘ

How these facts were elicited

Referenced by (13)

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

Factory Method → alsoKnownAs → Factory Method Pattern ⓘ
linked to: Factory Method
Abstract Factory → relatedTo → Factory Method ⓘ
Abstract Factory → oftenImplementedWith → Factory Method ⓘ
Builder → relatedTo → Factory Method pattern ⓘ
linked to: Factory Method
Prototype → relatedTo → Factory Method ⓘ
Flyweight → oftenUsedWith → Factory Method pattern ⓘ
linked to: Factory Method
Template Method → relatedTo → Factory Method pattern ⓘ
linked to: Factory Method
Singleton → relatedTo → Factory Method pattern ⓘ
linked to: Factory Method
Iterator design pattern → relatedTo → Factory Method design pattern ⓘ
linked to: Factory Method
Iterator pattern → relatedTo → Factory Method pattern ⓘ
linked to: Factory Method
Strategy (design pattern) → relatedTo → Factory Method (design pattern) ⓘ
linked to: Factory Method
Gang of Four design pattern → hasExample → Factory Method pattern ⓘ
linked to: Factory Method