DEV Community

loading...

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

Collapse
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?

Collapse
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.