Get rid of lousy "Method-Invocation-Chaining"-trick
David M. Lloyd
david.lloyd at redhat.com
Mon Apr 27 17:21:38 UTC 2009
On 04/27/2009 12:10 PM, Ulf Zibis wrote:
> Hi all,
>
> IMHO, implementing "Method-Invocation-Chaining" by simply returning
> "this" from regarding methods in Java-API was bad idea, because it
> doesn't really work, if a class is subclassed. For example see XxxBuffer
> classes, subclassed from java.nio.Buffer.
That's not exactly accurate. Return types may be covariant (and in the
case of Buffer, they should have been - I think it was just an oversight
that may be addressed in NIO.2 if I recall correctly). And in fact this
usage has worked out just fine for me.
Don't fix what isn't broken IMO
- DML
More information about the core-libs-dev
mailing list