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 (3)
| Label | Occurrences |
|---|---|
| Factory Method canonical | 4 |
| Factory Method pattern | 3 |
| Factory Method Pattern | 1 |
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.
Design Patterns: Elements of Reusable Object-Oriented Software
→
describesPattern
→
Factory Method
ⓘ
this entity surface form:
Factory Method Pattern
this entity surface form:
Factory Method pattern
this entity surface form:
Factory Method pattern