News for hackers. Stuff that matters.
Re:The Rust I wanted had no future by hadrien01 on Monday June 05, 2023 @09:31AM (#36195947)
The language doesn't push you towards interfaces implemented once, but many developers indeed persist doing it for no reason at all. With proper code review we're able to make that practice go away on the projects I'm working on.
Re:The Rust I wanted had no future by vips7L on Monday June 05, 2023 @09:56AM (#36196210)
Isn't this just mostly an issue with mock testing in C#? Developers cargo cult single implementation interfaces because its so hard to mock concrete classes.
Re:The Rust I wanted had no future by za3faran on Monday June 05, 2023 @01:36PM (#36199884)
I've seen the same in golang, which ironically is supposed to be vehemently against OOP.
Re:The Rust I wanted had no future by rjbwork on Monday June 05, 2023 @04:10PM (#36202838)
>Isn't this just mostly an issue with mock testing in C#

Yes. You have two choices: Interface implemented once, or virtual on all your public members.

I personally think Interface is the sane choice.

Would be nice if the .NET devs let us mock POCO's though...

Re:The Rust I wanted had no future by hadrien01 on Monday June 05, 2023 @05:46PM (#36204319)
You can mock (well, "fake") POCOs with packages like AutoFixture that use reflection to generate mostly fake data, depending on what you need. You don't need interfaces or virtual, but you do need public getters unfortunately.
Re:The Rust I wanted had no future by diarrhea on Monday June 05, 2023 @02:19PM (#36200641)
Lots (all?) major frameworks push for dependency injection though, where interfaces are a must, as far as I know (not for DI-the-principle, but DI-as-implemented). ASP.Net Core is a good example. It's not C# at the language level forcing interface-driven development, but frameworks like ASP.Net are so tightly integrated that boundaries blur.
Re:The Rust I wanted had no future by zamalek on Monday June 05, 2023 @05:28PM (#36203968)
Yup, that's what I meant by "practically." Nobody forces you to use the Microsoft.x nuget packages, but good luck at finding packages that don't rely on Microsoft.DI, or Microsoft.Hosting, or what-have-you.
Re:The Rust I wanted had no future by hadrien01 on Monday June 05, 2023 @05:42PM (#36204255)
You don't need interfaces for dependency injection, you can inject classes directly. I see interfaces more for separation of concerns (with domain-driven design pushed from all parts in the .NET world at the moment...), but that's not an obligation.
Re:The Rust I wanted had no future by rowls66 on Tuesday June 06, 2023 @09:04AM (#36212028)
I have seen way too much of interfaces implemented once in Java, and have argued against it unsuccessfully many times. I am not working in Go, and see the same.