So I am reading through the Oracle Java tutorial for interfaces, and they say that interfaces are a way of establishing contracts on how code interacts and/or that they can be used as a way to expose the methods of your proprietary software (like an API).
Okay, I can appreciate this, but then they introduce default methods.
The point of default methods is to add on functionality later. I get that you can't just add on another abstract method signature to an interface because then any classes implementing that interface will break, but the way I see it default methods mitigate the whole point of interfaces. You can't use them if you are creating proprietary software, because then you can't publish the interface directly. If you do you expose the body of your default method. Doesn't that defeat the purpose of trying to hide your proprietary code? It isn't as bad with the "contract" use case for interfaces, because class implementers can just write their own version. But in that case, why would they bother, because "if it ain't broke, don't fix it".
Anyway, my takeaway is to just use a versioning system instead even bothering with default methods. That way if a class implementer appreciates the new functionality brought on by a new version of an interface they can just upgrade to that new version. And versioning solves the API issue where we don't want to expose the body of proprietary default method
However, there is one point about the version system. The tutorial uses DoItPlus as the updated version of DoIt. This seems childish since what would the next version be, DoItPlusPlus? There has to be a way to do proper versioning in Java.
The point I am driving at is What is the point of default methods? and Does anyone use them?
Edit: I suck at writing.