Path: csiph.com!x330-a1.tempe.blueboxinc.net!aioe.org!matrix.darkstorm.co.uk!news.albasani.net!.POSTED!not-for-mail From: Lew Newsgroups: comp.lang.java.programmer Subject: Re: streaming problem and thread freeze Date: Tue, 10 May 2011 17:26:00 -0400 Organization: albasani.net Lines: 50 Message-ID: References: <005a9e79-36fe-4bf1-aa1d-bda3a5aaebf2@glegroupsg2000goo.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net Eki/ODxMJf/mJGtQ/KuDeFC0IM0lZtUb1HPuWPUe8iaOFgnYv4EUj7ZU7U+srpqiz4RT7Omaq8KGI8iXVRWlKBxVM/TeAqFvi+j5bPDbdxLcVrgOU0GDrcAFyETvdxIQ NNTP-Posting-Date: Tue, 10 May 2011 21:25:54 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="uQADZA4Mhh+bhZ1Y8X+IrS5c/8TRM8Vhiy2vqrxjE7R4dRJos8cWnjFrFZxEV3c2h2XQa3fFYkR2DSy4ospGrxkh4auixOLtneMNCbBmhW1mztC/RRuJ4cb4Fec2BFQ5"; mail-complaints-to="abuse@albasani.net" User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110424 Thunderbird/3.1.10 In-Reply-To: Cancel-Lock: sha1:FBiVy1b9hDjk9kI910n+J5rtaaI= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:3938 On 05/10/2011 03:17 PM, Daniele Futtorovic wrote: > On 10/05/2011 05:31, Lawrence D'Oliveiro allegedly wrote: >> In message, Daniele Futtorovic wrote: >> >>> Secondly, although it is only a minor thing and only my personal >>> opinion, this: >>> >>> } catch (IOException ex) { >>> log.severe(ex.getMessage()); >>> } >>> >>> is a *very* bad idea. Log the full stack. >> >> It would be so much easier if you could simply not bother to catch the >> exception at all, and let your program crash with a full stack trace. > > It would be yet much easier, as you perhaps one day will learn, to realise > that checked exceptions are not a bother, but an almost invaluable tool. > > And in cases you have to do something dirty, you can still simply throw an Error. You raise a good, if classically controversial, point, the overarching question of how properly to use exceptions. I, too, am partisan to the checked exception from two perspectives - that of the maintainer, and that of the API designer. You don't have to use them, given the rich hierarchy of Throwables, but they sure can be useful. Complaints about checked exceptions come pretty much exclusively from programmers using APIs that require'em. Hmm. I recommend to such folks that they consider a question, "What purpose does this particular checked exception serve in the method contract?" Whether you agree or not, the API designer had an answer to that question. They have ensured that all clients benefit from their reasoning. API designers that make different decisions might use runtime exceptions or some other mechanism. It's not really a bad thing nor even confusing to a reasonably-trained programmer to have 'catch' blocks all over the place, no more than the similar amount of decision blocks one needs for thorough, professional programming. Code that serves a purpose isn't bloat, and code that creates a reliable invariant isn't a digression. If you can't stand the heat, get out of the kitchen. -- Lew Honi soit qui mal y pense. http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg