Path: csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: markspace <-@.> Newsgroups: comp.lang.java.programmer Subject: Re: can't throw Date: Wed, 12 Sep 2012 10:56:17 -0700 Organization: A noiseless patient Spider Lines: 34 Message-ID: References: <19af6b94-7a1e-4491-afb2-79782406f560@googlegroups.com> <504fe3a6$0$293$14726298@news.sunsite.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 12 Sep 2012 17:56:20 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="61282af8d6595e8d991edb5ac03d6e00"; logging-data="20271"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/zGIDqycJE5cDB0wDNjkzkNJ9eZaLsrmE=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20120824 Thunderbird/15.0 In-Reply-To: Cancel-Lock: sha1:Cq5KBCSFSVkZvNH9TV0gs1m+OOI= Xref: csiph.com comp.lang.java.programmer:18683 On 9/12/2012 9:18 AM, Gene Wirchenko wrote: > I prefer reading the main flow of execution as a high-level > story. Catches interrupt this. When there are a lot of catches, they > make the main code harder to find. Well true, but these sorts of things yield easily to a little thought and planning. Given some method or collection of methods that throw a lot of exceptions, throwsALot(), you can just separate out the exception handling from the rest of the code. private void implementation() throws This, That, Another { throwsALot(); } public void handlers() { try { implementation(); } catch( This ex ) { } catch( That ex ) { } catch( Another ex ) { } Now at least your bothersome exception handling is separate from your implementation, and you can read the code a bit more easily. One exception in Java 7 is probably AutoClosable, which you should probably take advantage of when available.