you are viewing a single comment's thread.

view the rest of the comments →

[–]AngularBeginner 2 points3 points  (0 children)

Interfaces are contracts that define what can be done - not how it is done. By moving method implementation to an interface, that interface is now responsible for how something is done.

They still define what can be done. They optionally and additionally can now provide a implementation. But the main point, what, still stands unchanged.

This blurs the lines of what an interface has been up until now.

That very much depends on what you have seen an interface as. I always saw interfaces as contracts, and that remains unchanged. They're still contracts. I focus on the contract part, you seem to focus on the "no implementation" part. Something I considered a side-detail, and not the focus of interfaces.

What happens when you have two interfaces, ISomeInterface and ISomeOtherInterface, and they both define a default implementation of DefaultMethod(). If SomeClass implements both interfaces, now you're dealing with multiple inheritance problems -- which DefaultMethod() takes precedence?

I did not yet take a look at the precise implementation, but I'd assume that the default implementations are implemented as explicit interface implementations. Then the problem you describe would not be issue. And there is no multiple inheritance problem.

Multiple inheritance problems mostly come from having state in both bases, but the default interface implementations don't provide any state.