Re: Interface freeloading on a superclass - is it good practice?



> I'm not sure I understand how this is primarily a "bad use of
interface"
> problem as opposed to a "depending on undocumented behaviour" problem. I

Not even necessarily "undocumented behaviour". How many times have you seen
the latest JDK release notes state in the incompatible changes section
"method x was broken in our previous releases. It has now been reimplemented
to do X, and X is from now on the official documentation for that method x."
? In an ideal world that would never happen, but we live in a far-from ideal
reality...

> think you'd have the exact same problem if you used one of Sun's classes
in
> composition and depended on a particular behaviour; if Sun changed the
> behaviour, your code wouldn't work anymore.

Of course, but the OP will compound the problem by creating an interface at
the *top* of a hierarchy... breaking everything downstream if Sun fiddles
the semantics of one of "his" methods. That's at least as bad as some
regression bugs due to delegating (composition) to objects whose behaviour
have subtly changed from one JDK release to the next.

> I'd imagine typically that if one were to create an interface for a
> particular set of methods from one of Sun's classes, the documentation
> explaining the semantics of those methods would pretty much be taken
> straight from Sun's javadocs. Then the interface creates no new
restrictions
> on behaviour that weren't already publicly documented on Sun's site.

True, true, but the OP is not the prime maintainer of those semantics and
their documentation... Sun is. And that's the whole problem. Nobody can just
take snapshots of implementations by way of declaring an interface for
existing core API methods, and expect third parties like Sun to suddenly
honour those frozen semantics for the rest of time.

Right, I think I flogged my explanation to death... you either get it or you
don't... I gave it my best shot :-)


.



Relevant Pages

  • Re: Interface freeloading on a superclass - is it good practice?
    ... > Who's talking about changing any method signatures? ... > the subject of any interface contracts written by the same authors of the ... any future changes to the *precise semantics* of the methods ... Because Sun don't know or care about your interface's rigid semantic ...
    (comp.lang.java.programmer)
  • Re: IStream.Read()
    ... I would say that the documentation for the actual .NET ... type is superceeded by the documentation for the IStream interface itself, ... You can set this pointer to NULL. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How to get the documents in detail?
    ... Not MSDN Library. ... anyone trying to learn how/when to use a particular interface (I guess ... A halfway decent documentation on this interface would have put the ... blah blah blah is an example of a possible site and a yeah yeah yeah ...
    (microsoft.public.vc.atl)
  • Re: input from keyboard
    ... What's needed are documentation and examples. ... Xlib code to my program because on every Linux system Xlib ... One of the reasons you use the libraries is so you don't have to worry about those things. ... you tried to bypass the C interface to Windows and use its internals. ...
    (alt.lang.asm)
  • Re: Great SWT Program
    ... make custom Swing components and L&Fs to get a UI that should be ... files whose locations weren't discoverable via documentation. ... Usually, they provide their own interface to change the information, ... The registry has a global search. ...
    (comp.lang.java.programmer)