On Sun, Jan 30, 2011 at 7:10 PM, Jörn Kottmann <[email protected]> wrote: > I am pretty sure with the Iterator interface people tend to do the > following mistakes frequently: > - Assuming no exception can be thrown
I agree this could be a problem for people who rely only on the compiler and not on the documentation. > - Not understanding that writing a second for-each implies a reset of the > stream I agree this could be a problem, though this is how the for-each works for everything else so I don't think it would be too surprising. > - Not using try-finally to safely close the Iterators I don't agree this is a problem because of Iterators. It's just as easy to leave off the try-finally with the ObjectStream API. Maybe Java should introduce compile time checked try/finally blocks. ;-) > - Only expecting IOExceptions when they are declared as throws > (like in your example) but not also a RuntimeIOException I agree this could be a problem, again, for folks who don't read documentation. Anyway, I've given my best shot on this discussion, and I think we've pretty much reached an impasse, where I'm more concerned about ease of use and interop with other Java libraries and you're more concerned about making it harder to accidentally write code that doesn't expect all the exceptions that could arise from it. Could you at least document some version of this discussion (e.g. the three valid points above) in the documentation for ObjectStream? That way when future users think "gee it would be nice if this used the Iterator API", they'll see immediately why you've chosen not to. Steve -- Where did you get that preposterous hypothesis? Did Steve tell you that? --- The Hiphopopotamus
