• fuck_u_spez@lemmy.fmhy.mlOP
    link
    fedilink
    arrow-up
    3
    ·
    1 year ago

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

    • bjornsno@lemm.ee
      link
      fedilink
      arrow-up
      3
      ·
      1 year ago

      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.

      • fuck_u_spez@lemmy.fmhy.mlOP
        link
        fedilink
        arrow-up
        1
        ·
        1 year ago

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