Sponsored Link •
|
Advertisement
|
Advertisement
|
This page contains an archived post to the Design Forum (formerly called the Flexible Java Forum) made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.
Message:
Like Bill, I also recall battling with the notion of a Java interface when Java first hit the scene. Oooo, but I thought multiple inheritance was sooo BAD! Not so. If it were, only BAD programmers would use Java interfaces, and clearly this is not the case. MI has, in fact, just one problem: A bad reputation, which stems almost solely from C++�s appalling support for MI. Java interface advantages: Java interface disadvantages: Unlike some other notable kludges of the Java language (primitive types, fixed package names), Java interfaces actually work surprisingly well in practice. Nevertheless, I could easily envisage seeing negative consequences of interfaces at a later stage of Java�s evolution. For example, suppose Java should one day fully support Design by Contract. Full support would allow us to go beyond a mere method signature in a Java interface and make it possible to specify semantic constraints (pre- and postconditions). Such constraints must, of course, be inherited, but what happens if two interfaces specify two distinct (potentially conflicting) sets of semantic constraints for methods sharing the same signature? Now we notice that the naming conflict has been with us all along! Just imagine the same situation with totally conflicting comments or usage notes associated with those multiply inherited methods. Anyone feel differently? Replies:
|
Sponsored Links
|