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?
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.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
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?
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.