On Fri, Jun 25, 2010 at 20:25, Reinier Zwitserloot <[email protected]> wrote: > I just don't get IDEs. Eclipse does something similar > (e.printStackTrace() I believe). This, AND what netbeans does, is > completely ridiculous. Almost always the wrong thing. The only obvious > thing to do when automatically generating an exception handler, is > this: > > catch (CheckedEx e) { > throw new RuntimeException("missing handler", e); > }
Uhhhh - I would never ever do this. 1. Just because Microsoft did not implement checked exceptions it does not mean, .NET does it better. I for myself appreciate the checked exceptions. They make a lot of sense. People complaining about boilerplate code generated are using it wrong IMHO. It is similar to copying a file. There is no ready made method in the Java libraries to copy a file and when learning Java I REALLY wondered why there isn't. The conclusion I had after a while: There are so many ways and possible requirements when copying a file that everybody needs to write a copy function as required. For opening a file I have written several wrappers for the most frequent use cases I have. Then I use the wrapper and don't have to handle the checked exceptions again and again wherever I open files. And of course there are libraries and methods that make too much use of checked exceptions (I think it is some method in the net package that throws 3 or 4 checked exceptions that needs to be handled (don't remember exactly) - however I wrote a wrapper for my 90% use case and done. Anyway I had several discussions with .net and Java developers and I prefer the way it is designed in Java. 2. A runtime exception means, that the developer is not pushed to implement a handler which means the developer can easily forget to handle an error that possibly is produced by a called method. Out-of-memory errors are a good example of where runtime exceptions make sense, where it does not make sense to try anything further. On the other hand, an I/O error is not in general a reason to vomit and do an epic fail. It rather makes sense to try again because it might be a short interrupt of network connection. I have seen several Windows applications completely crashing because network connection was missing for 5 or 10 seconds. > That logger action just lets the process continue, while the state is > most likely corrupted. Horrible solution. Indeed! - The last thing I ever want, is my application crashing - this is the worst user experience on the client (all edits lost) and completely stopping the service for a server application (assuming it is the main thread where the error occurs). An application should always come to a graceful end. -- Martin Wildam -- You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.
