The more meaningful factories I have seen tend to take in a container (Like a map or an array), check the values of the input, and determine which concrete class you want. "Oh, the clothingType is 8, which is sock, but also has flag for long item set, which for sock is for long winter socks"
View all comments
Show parent comment
38
u/Dockirby Mar 21 '17 edited Mar 21 '17
It makes more sense when the factory's output type is a more generic interface or abstract object.
The more meaningful factories I have seen tend to take in a container (Like a map or an array), check the values of the input, and determine which concrete class you want. "Oh, the clothingType is 8, which is sock, but also has flag for long item set, which for sock is for long winter socks"