News for hackers. Stuff that matters.
Re:Interfaces Generally Belong with Users by LessDmesg on Sunday November 24, 2019 @02:14AM (#21618937)
This is wrong, bad advice, for the same reasons that structural typing is wrong and nominal typing is right. It goes against all OOP and modularity principles. Interfaces should never be declared at the use site because an interface is a contract promised by the implementor.

As for the example, it feels contrived and unprofessional. There should never be a monolithic "Backend" type. Functionality should be separated into services, each one with an interface, and each one injected dynamically for easy testability and upgradeability.

Re:Interfaces Generally Belong with Users by Nitramp on Sunday November 24, 2019 @03:48AM (#21619194)
> [this is wrong] because an interface is a contract promised by the implementor.

I think the point the article makes is that you can instead think of an interface as a list of requirements demanded by a user (so your criticism here is a bit of a tautology). The article backs this up by describing concrete advantages of that approach.

Maybe you could share why (or whether) you think these don't apply, or how they contrast with your preferred approach?

Re:Interfaces Generally Belong with Users by LessDmesg on Sunday November 24, 2019 @04:07AM (#21619254)
It's all in the books. Gang of Four, etc. Learn from good books instead of bloggers who have a type called "Backend" and make brilliant discoveries that DI and nominal typibg are bad despite the whole industry using them successfully.
Re:Interfaces Generally Belong with Users by Nitramp on Sunday November 24, 2019 @04:32AM (#21619312)
> It's all in the books. Gang of Four, etc.

No worries, I've read the usual suspects. Taking your example of Gang of Four though (and this applies similarly to the other usual suspects), it definitely does not discuss this observation (and potential trade offs), given it predates common use of structural type systems by far.

I think as professional engineers it behooves us well to prefer actual argument and exposition of engineering tradeoffs over authority ("whole industry does it", "learn from good books").

Re:Interfaces Generally Belong with Users by jcelerier on Sunday November 24, 2019 @11:42AM (#21621493)
> I think as professional engineers it behooves us well to prefer actual argument and exposition of engineering tradeoffs over authority ("whole industry does it", "learn from good books").

That really depends on what you want to achieve. e.g. if you want to retain the possibility to fire a whole team and replace it with newcomers, or external contractors, at any point in the development cycle, it is muuuuch safer to stick to what is taught in most schools (which is "tradtional OOP").

Re:Interfaces Generally Belong with Users by jayd16 on Sunday November 24, 2019 @05:14AM (#21619468)
Whats the big deal? Structural typing explores the concept that the implementer contract and the user requirement is separate and tries to gain some composability out of that. You still have the public methods as the implementer contract.
Re:Interfaces Generally Belong with Users by enriquto on Sunday November 24, 2019 @03:46AM (#21619188)
> It goes against all OOP and modularity principles.

Sounds good to me, then!

Re:Interfaces Generally Belong with Users by LessDmesg on Sunday November 24, 2019 @04:01AM (#21619235)
I hate the flavour of OOP present in C++/Java/C# as much as the next man, but the principles are sound. Defining the interface at the user side is like a conflict of interest, like a kangaroo court. It's just bad architecture.
Re:Interfaces Generally Belong with Users by sagichmal on Sunday November 24, 2019 @07:03AM (#21619891)
> Defining the interface at the user side is like a conflict of interest, like a kangaroo court. It's just bad architecture.

You're wrong.