🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.nntp
1 messages
1 total messages Started by terry Mon, 12 Mar 2007 19:25
Re: Why does Java require the throws clause? Good or bad language design?
#75540
Author: terry
Date: Mon, 12 Mar 2007 19:25
48 lines
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.)
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads