On 1/8/07, Martin Cooper <[EMAIL PROTECTED]> wrote:
On 1/8/07, Henri Yandell <[EMAIL PROTECTED]> wrote: > > On 1/8/07, Stephen Colebourne <[EMAIL PROTECTED]> wrote: > > Martin Cooper wrote: > > > Could you say more about this, please? I happen to disagree on > > > exceptions as > > > inner classes being a bad idea; FileUpload has done this for years, > without > > > any problems. But I'm always interested in hearing new perspectives... > > > > I guess its stylistic, and therefore subjective. But I see an exception > > as a critical system object, and not one that should be relegated to > > inner class status. > > +1 > > } catch( DirectoryWalker.CancellationException ce) { > ... > } > > feels weak to me.Weak why?
Because I'm not used to it I suspect. It's not a common idiom so not something my eyes naturally parse, and if I was writing the code I suspect it would take a bit longer to write. Not char-wise, I mean in terms of realising what I was meant to catch. Stephen mentioned the javadoc. Looking at that, I doubt I'd be catching DirectoryWalker.CancellationException anyway - the method that it is thrown from throws IOException. The DirectoryWalker.CancellationException isn't in its contract, except as an argument passed in. The examples in the Javadoc look bad btw. They refer to CancelException and not DirectoryWalker.CancellationException.
To me, it makes the code very explicit about what is being cancelled. It also, by the way, allows for other classes to have a CancellationException without having to make up some other name, because the enclosing class scopes the exception class name and allows its reuse in other classes. It seems like an eminently suitable way of naming / scoping tightly coupled classes such as we see with these types of exceptions.
Good arguments - though they just make me think in terms of a more specific class name - "WalkCancelledException". Hen --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
