Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.java.programmer Subject: Re: can't throw Date: Wed, 12 Sep 2012 19:09:22 +0200 Lines: 30 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 X-Trace: individual.net zAgEF7MYSZSOu66BNaFvIQYAPV4lb8ZF5sk0frAyS4oaCU+kNQqKTxxli+xSMdrpc= Cancel-Lock: sha1:0TC3yCcBMfMLu/X8yqdB+GffeyA= User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:15.0) Gecko/20120907 Thunderbird/15.0.1 In-Reply-To: Xref: csiph.com comp.lang.java.programmer:18679 On 12.09.2012 18:18, Gene Wirchenko wrote: > To me, it also seems as if it would be a good idea, but using it > is awkward. In some coursework, I used a Java cryptographic system. > It had a lot of exceptions to handle so my code had a lot of catches. > Because I did not know what was thrown, I wrote my code without them > and then added whatever the compiler stated was missing. In those > catches, there really was not anything that I could do other than > reporting the error. Well, but that's a valid way to handle an exception. :-) > 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. I my experience that can at least partially be attributed to people putting several try catch blocks in a method or not making them the outermost "bracket" of the method. I frequently see a return after the closing bracket or such thing which makes it harder to read (and decide what happens in case of error and OK) and - more importantly - impossible for the compiler to catch control flow errors (e.g. the final return returns true while in case of error you wanted to return false). Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/