5 ms·
One of the major innovations I miss still in C# is more flexibility regarding interfaces and inheritance. Like e.g. protocols in Swift. Their synthesized imple
by yayr 5y ago
One of the major innovations I miss still in C# is more flexibility regarding interfaces and inheritance.
Like e.g. protocols in Swift. Their synthesized implementations are a great and productive method to ensure standardization and code reuse without much boilerplate.
C# is still on the old OO path coming from Java with respect to that and decorating something with multiple base implementations is still a pain.
- int_19h 5y agoMultiple inheritance of code is possible with interfaces and default methods.
- yayr 5y agothanks, C# 8.0 indeed seems to bring that, awesome. https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-8.0/default-interface-methods https://docs.microsoft.com/en-us/dotnet/csharp/language-refe...
- logbiscuitswave 5y agoI totally agree. The protocols feature of Swift is really cool and it’s great how simple it bridges default implementations and extension methods. C# 8.0 adds default interfaces which are like protocols but they don’t work with older .NET Fx code. I’m working on a C# project right now where default interface implementations would save me thousands of lines of kludges with extension methods and duplicated class code. Sadly, it’s stuck on .NET 4.8 and can’t be migrated to .NET 6 right now.