DEV Community

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

Collapse
tyrrrz profile image
Alexey Golub

So the old monolith code used to prepend "[error]" in its own so you've added new methods and you have to change the consuming code so that it uses them instead. If you have to update consuming code anyway, why not make a breaking change in the interface instead and do it properly?

Collapse
lolle2000la profile image
Lolle2000la Author

Because you don't want to break the existing consuming, and most importantly the implementing code.

Collapse
tyrrrz profile image
Alexey Golub

You didn't break it on paper, i.e. it's binary-compatible, but not semantically compatible, since you still have to update existing code to use the new API correctly.

Thread Thread
lolle2000la profile image
Lolle2000la Author • Edited

I agree, that's misunderstandable on my end. The point is that you can use the new API. Using it doesn't break the old implementation

Collapse
jessekphillips profile image
Jesse Phillips

The interface breaking implementation does not break consuming code.

What the default method brings is the ability for consuming code to use the new methods without the need to update the logging library, only the logging library contract. But this gets into layers of control and ownership.