DEV Community

Discussion on: Why interface default implementations in C# are a great thing

Collapse
 
costinmanda profile image
Costin Manda

Depending on what extension method class you are referencing, I guess. Never tried having different extension classes with the same signature, though. As I said, it would be ugly.

However, if you first refactor any codebase to use dependency injection, replacing one implementation with another becomes infinitely easy, not to mention testable, but it is a great step to make and many old code doesn't warrant that much effort.

My fear is that there will again be huge 500+ method interfaces and their reason d'etre will be "well, override only what you actually need". There is something inherently evil in interfaces with optional members, like a contract with a fine print, or one of those checkbox menus for marketing :)

Thread Thread
 
lolle2000la profile image
Lolle2000la

I agree, I have also thought about the possibility. I'm the beginning we had a similar problem with extension methods which had stuff like int.GetElementFromProductsTable() (of course a very hyperbolic example).

After people had understood how to use them correctly, extension methods became really useful and liked, but before many (and some still to this Date) habe believed they are cancer for C#.

I think default interface implementations will make a similar journey!