Btw. why don’t interfaces work + “as argument” (whether it’s a constructor in an OOP context or a function parameter)? I think interfaces are exactly built for such a use-case (without all the boilerplate that’s necessary with dependency injection as well as factories).
What are you talking about? At least in Java and PHP you can absolutely declare constructor and function parameters as interfaces. As you say that’s exactly what they’re for.
Yeah that’s my point, I don’t see a use for factories here, because it’s possible to just use generic parameters (whether it’s constructors or function arguments).
Btw. why don’t interfaces work + “as argument” (whether it’s a constructor in an OOP context or a function parameter)? I think interfaces are exactly built for such a use-case (without all the boilerplate that’s necessary with dependency injection as well as factories).
What are you talking about? At least in Java and PHP you can absolutely declare constructor and function parameters as interfaces. As you say that’s exactly what they’re for.
Yeah that’s my point, I don’t see a use for factories here, because it’s possible to just use generic parameters (whether it’s constructors or function arguments).