DEV Community


Discussion on: The Factory Pattern - Design Patterns meet the Frontend

jannikwempe profile image
Jannik Wempe

Thanks for explanation and the good examples :-)
As you said, you don't like the fact that it relies on inheritance: wouldn't it be possible to create a factory that uses composition instead?

coly010 profile image
Colum Ferry Author

I'm not entirely sure. I mean, you could essentially have a bunch of behaviour classes that you piece together within the factory and return that new object, but I feel like that borders a different pattern, The Builder Pattern, potentially.