Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: 4ndre4 <4ndre4@4ndre4.com.invalid> Newsgroups: comp.lang.java.programmer Subject: Re: Java Checked Exception is BAD! Date: Thu, 4 Feb 2016 21:07:01 +0000 Organization: A noiseless patient Spider Lines: 46 Message-ID: References: <00ab9f4e-0f06-48ec-9a65-1a150c129a39@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 4 Feb 2016 21:04:12 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="b0729cc7037a278faf4b924545edb85b"; logging-data="17205"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/JXsZajwk1SRBYJ2u2fsPx" User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 In-Reply-To: <00ab9f4e-0f06-48ec-9a65-1a150c129a39@googlegroups.com> Cancel-Lock: sha1:Tak6sb8aQQlbrCyM3dMtOSCBw+w= Xref: csiph.com comp.lang.java.programmer:33597 On 04/02/2016 15:18, boxzou@gmail.com wrote: [...] > http://tri-katch.blogspot.com/2016/02/java-checked-exception-is-bad.html > > In the above link I proved in theory why checked exception is BAD. Erm... I was expecting a much longer and much more enlightening disseration. You have just repeated some of the known flaws of checked exceptions without saying anything really new. In his item #59, Joshua Bloch[1] says "Checked exceptions are a wonderful feature of the Java programming language. Unlike return codes, they force the programmer to deal with exceptional conditions, greatly enhancing reliability. That said, overuse of checked exceptions can make an API far less pleasant to use." and he goes on explaining the reasons why you shouldn't overusethem. You'd better read that book. You say "Exception is supposed to be handled exceptionally, i.e. rarely. But checked exception contradicts this principle by forcing the caller to handle it right after a method call" I don't think that forcing the developer to handle the exception is a contradiction of the principle that exceptions should be handled exceptionally. What you, as a developer, are required to provide, is some code that deals with the exception in those (supposedly) rare case when it will happen. "it turns really ugly to see 3 or more exceptions" If you're method is throwing too many exceptions, it is likely that your method is doing more than it is supposed to do. "And any non-trivial software system would have far more than 3 exceptional conditions!" Supposedly not thrown by the same method. [1] Effective Java, 2nd ed., p.246. -- 4ndre4 "The use of COBOL cripples the mind; its teaching should, therefore, be regarded as a criminal offense." (E. Dijkstra)