https://github.com/quynhchi1009/factorymethod
Factory Method is a creational design pattern that provides an interface for creating objects in a superclass, but allows subclasses to alter the type of objects that will be created.
https://github.com/quynhchi1009/factorymethod
design-patterns factory-method factory-method-pattern
Last synced: 6 months ago
JSON representation
Factory Method is a creational design pattern that provides an interface for creating objects in a superclass, but allows subclasses to alter the type of objects that will be created.
- Host: GitHub
- URL: https://github.com/quynhchi1009/factorymethod
- Owner: quynhchi1009
- Created: 2022-12-04T16:28:45.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-12-04T16:32:38.000Z (about 3 years ago)
- Last Synced: 2025-03-04T16:14:34.392Z (11 months ago)
- Topics: design-patterns, factory-method, factory-method-pattern
- Language: Java
- Homepage:
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FactoryMethod
Factory Method is a creational design pattern that provides an interface for creating objects in a superclass, but allows subclasses to alter the type of objects that will be created.
1. Replace direct object construction calls (using the new operator) with calls to a special factory method.
2. Limitation: subclasses may return different types of products <=> these products have a common base class or interface.
3. Use when:
- don’t know beforehand the exact types and dependencies of the objects your code should work with
- want to provide users of your library or framework with a way to extend its internal components.
- want to save system resources by reusing existing objects instead of rebuilding them each time.
Source: https://refactoring.guru/design-patterns/factory-method