Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

From a versioning perspective, what are the drawbacks of extending an interface as opposed to extending a class?

0
Posted

From a versioning perspective, what are the drawbacks of extending an interface as opposed to extending a class?

0

With regards to versioning, interfaces are less flexible than classes. With a class, you can ship version 1 and then in version 2 decide to add another method. As long as the method is not abstract (i.e. as long as you provide a default implementation of the method), any existing derived classes continue to function with no changes. Because interfaces do not support implementation inheritance, this same pattern does not hold for interfaces. Adding a method to an interface is like adding an abstract method to a base class–any class that implements the interface will break because the class doesn’t implement the new interface method.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123