Article View: news.software.nntp
Article #75540Re: Why does Java require the throws clause? Good or bad language design?
From: terry
Date: Mon, 12 Mar 2007 19:25
Date: Mon, 12 Mar 2007 19:25
48 lines
3318 bytes
3318 bytes
In article <20070208111322.GB5007@morgenes.shire.sytes.net>, Robbert Haarman
<comp.lang.misc@inglorion.net> wrote:
>On Thu, Feb 08, 2007 at 10:44:18AM +0000, Bent C Dalager wrote:
>> And, of course,
>> public void foo(Object... args) throws Throwable
>> may be just the silver bullet we are looking for . . .
>
>It is true that this removes the effort of changing the declaratiens in
>response to refactoring, but Java will still impose burdens on the
>programmer. First, they have to actually type "Object" before every
>argument and "throws Throwable" after every method declaration.
throws Throwable means your very design is incorrect
as you are entirely missing the granularity of your errors.
You'll never be able to successfuly recover
and forget about reattempting the operation
on a fine grained level as you will be thrown
several layers up.
>Secondly, if you actually want to use these arguments and throwables,
>you will have to downcast them to another class, because Object and
>Throwable probably don't have the methods and fields you need. This
>requires more typing. It also incurs a performance penalty, because the
>casts will be checked at run time. In the end, you get the worst of
>dynamic typing and the worst of mandatory declarations, all in one
>program.
A BASIC rule in object oriented programming:
DO NOT USE CASTS.
Unless it is absolutely unavoidable.
>Regards,
>
>Bob
>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"There's not going to be enough people in the system
to take advantage of people like me."
--- Adolph Bush,
On the coming Social Security crisis;
Wilton, Conn.; June 9, 2000 (Thanks to Andy Mais.)
Technical Details
Message-ID:
<5xe5ka$4mi$4@centurytel.net>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!number1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!novia!newsfeed.gamma.ru!Gamma.RU!image.surnet.ru!news1.lucky.net!carrier.kiev.ua!news.te.net.ua!postnews.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!130.81.64.211.MISMATCH!cycny01.gnilink.net!spamkiller2.gnilink.net!gnilink.net!trndny04.POSTED!760c3fd9!houston.rr.com!terryReferences:
<1170835862.972715.24740@v33g2000cwv.googlegroups.com> <45c9a593$0$765$5a6aecb4@news.aaisp.net.uk> <gcudnTZig-sMTFTYnZ2dnUVZ_uGjnZ2d@comcast.com> <eqeuu2$tec$1@orkan.itea.ntnu.no> <20070208111322.GB5007@morgenes.shire.sytes.net>Show Full Headers
Complete Article Headers
Message-ID: <5xe5ka$4mi$4@centurytel.net> Subject: Re: Why does Java require the throws clause? Good or bad language design? Date: Mon, 12 Mar 2007 19:25:17 GMT From: terry@houston.rr.com References: <1170835862.972715.24740@v33g2000cwv.googlegroups.com> <45c9a593$0$765$5a6aecb4@news.aaisp.net.uk> <gcudnTZig-sMTFTYnZ2dnUVZ_uGjnZ2d@comcast.com> <eqeuu2$tec$1@orkan.itea.ntnu.no> <20070208111322.GB5007@morgenes.shire.sytes.net> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!number1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!novia!newsfeed.gamma.ru!Gamma.RU!image.surnet.ru!news1.lucky.net!carrier.kiev.ua!news.te.net.ua!postnews.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!130.81.64.211.MISMATCH!cycny01.gnilink.net!spamkiller2.gnilink.net!gnilink.net!trndny04.POSTED!760c3fd9!houston.rr.com!terry Newsgroups: news.groups, alt.slack, alt.config, news.software.nntp, alt.usenet.kooks alt.usenet.kooks Organization: Smashed Bikers Lines: 48 Approved: ceo@big8.orgy (Big-8 CEO) NNTP-Posting-Host: d134-75.tenet.odessa.ua X-Trace: toster.te.net.ua 1173743724 32039 195.138.75.134 (12 Mar 2007 X-Complaints-To: abuse@te.net.ua NNTP-Posting-Date: Mon, 12 Mar 2007 23:55:24 +0000 (UTC) X-Newsreader: Microsoft Outlook Express 4.72.3110.1