[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Java interface natural history was RE: "static" declaration
Anton van Straaten wrote:
>Oh definitely. Not having support for any implementation reuse mechanism
>other than single inheritance is a harsh restriction, in a system that
>supports multiple interfaces on classes, and I'm sure it inhibits use of
>interfaces in Java.
I don't think so.
It was my experience, though, that my co-workers were somewhat hesitant
to use interfaces
to their fullest, because they considered it a drag to have to implement
an interface, and then
implement a base class that contains various default behavior. Having
both things seemed like
too much work for too little benefit. I, personally, think it's the
Right Thing to clearly separate
the interface (the outward-facing spec) from the base class (a
particular bag of default
implementation stuff that some implementations might want to use and
other might not), but
I am not unsympathetic with their point and I don't have a Great Unified
In none of these cases did the need for multiple inheritance come up.
We worked on this
product for several years and just didn't need multiple inheritance
>>Your message made me curious about how interfaces are actually
>>used in Java.
>>Here's what i found by scanning JDK1.4's rt.jar:
>>Other jars could have a higher interface ratio, and certainly user code
>>might have more concrete classes that implement those interfaces.
>I suspect that some of the third-party libraries out there might have
>heavier use of interfaces, and I also have the impression that newer JDK
>code uses them more heavily than was done in earlier code that's still
>present in the JDK. My experience is that in "modern" Java programming (as
>opposed to the dark ages back at the dawn of time, around 1996), interfaces
>are being used pretty commonly and appropriately.
In my opinion, if you want to see "how things are really done by Java
programmers", it is not
a good idea to tacitly assume that the practices seen in the rt.jar
builtin library are good
predictors of what Java programmers do. The Java libraries were built
up over time and
have not (and cannot) be redone from scratch. Using interfaces used to
have a severe
performance penalty and a lot of the libraries were developed under
color of that