by java-man · 7y ago · 0 comments
I think the concept of coding to an interface (or an API specification) goes beyond what java did. In my professional life, I see people constantly downplaying and ignoring importance of a formal and stable API specification, just to suffer consequences later.
Said differently, can I download your .jar and write my own code to interface with it while on a desert island without any other resources?
If you have a random JAR file, an IDE can introspect it to see what classes are in it and what methods are in those classes.
The only exception is if you run it through some kind of obfuscator first.
1. 1/10 or 1/100 compile time
2. full introspection in regards to the interfaces (the topic of this discussion). the implementation classes could be obfuscated, but the point of an interface (and an API in general) that it is not.
3. one could possibly allow multiple versions of the interface be present on the same machine at the same time. for example, when SomeInterfaceV1 is replaced (or extended) by SomeInterfaceV2, it might be possible to provide an adapter that publishes the older interface for backward compatibility.
these are just random thoughts, because the difference between current systems written in c/c++ and a new architecture that uses interface-based approach is too great, I don't think I can name a real system that uses it in practice.
done the API versioning myself several times with complex applications though.