
Factory Pattern Use Case : Design Patterns in TypeScript
Design Patterns In TypeScript (book)
https://www.amazon.com/dp/B0948BCH24 : ASIN B0948BCH24
https://www.amazon.com/dp/B094716FD6 : ASIN B094716FD6
Documentation : https://sbcode.net/typescript/factory/#factory-use-case
An example use case may be a user interface where the user can select from a menu of items, such as chairs.
The user has been given a choice using some kind of navigation interface, and it is unknown what choice, or how many chairs the user will add until the application is actually running and the user starts using it.
So, when the user selected the chair, the factory then takes some property involved with that selection, such as an ID, Type or other attribute and then decides which relevant subclass to instantiate in order to return the appropriate object.
#factoryPattern
#typescriptFactory
#factoryPatternTypescript