Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #18779

Re: can't throw

Newsgroups comp.lang.java.programmer
Date 2012-09-14 14:28 -0700
References (6 earlier) <h7kuo77qjaim$.vgolgvvfs7kc.dlg@40tude.net> <ion658l9c0jpn2v239660jlctjqdath7bb@4ax.com> <abhck3Fdgb0U1@mid.individual.net> <hs3758lo2hrs884cagclm2lh72ijc1mk9b@4ax.com> <abhkjtFfcjaU1@mid.individual.net>
Message-ID <8d3ef5fc-c5a5-4ebd-9762-aaca2de41289@googlegroups.com> (permalink)
Subject Re: can't throw
From Lew <lewbloch@gmail.com>

Show all headers | View raw


 Robert Klemme wrote:
>  Gene Wirchenko wrote:
>>>>        It may not be nearly as elegant, but I still prefer BASIC's ON
>>>> ERROR GOTO handling.  Yes, one had to sort through the error numbers,
>>>> but that made it easier in some ways.  One could code something to
>>>> handle the few cases where there was a specific handling and then use
>>>> a catch-all for the rest.
> 
> >       I am not surprised.  Unfortunately, I never learned that.
> 
> > Beginning Java texts that I have seen do not cover it.  With BASIC,

Here you go, the cure for your ignorance of how to use Java exceptions:
http://docs.oracle.com/javase/tutorial/essential/exceptions/index.html

>> handling errors was with only one error handler so it was forced to do
>> it that way (and sometimes, it was covered).
> 
> I wasn't aware that this seems to be such a mystery.  The basic (!) 

It isn't if you read the tutorial.

The place where everyone is recommended to begin learning Java.

> mechanism is pretty simple: exception handler order matters: the first 
> matching handler is used.  So you can place handlers for classes down 

From the tutorial: " The runtime system invokes the exception handler 
"when the handler is the first one in the call stack whose ExceptionType 
matches the type of the exception thrown." 

> the exception inheritance hierarchy at the front and place handlers for 
> classes further up later.  In an extreme case use a catch block with 
> RuntimeException, Exception or Throwable as last one.

As illustrated in the tutorial: "By catching any IOException that's not caught 
by the first handler, . . . "

>>> I find the distinction between checked and unchecked exceptions pretty
>>> good - although the distribution of exception types across these

"The first kind of exception is the checked exception. These are exceptional 
conditions that a well-written application should anticipate and recover from."
  
>>> categories does not always seem to be wisely made in the standard library.
> 
>>       Java has too many distinctions that are not easily (or
> > often-enough) made and that can catch Java newbies.

Unless they read the tutorials.

>>       Maybe, it was too much of trying to be everything to everybody?

Maybe it was a case of not RTFM?

Blaming the language for one's failure to study is an unworthy act.

> I believe what you describe is rather an effect of the massive success 

This doesn't apply to exceptions, most of whose functionality has been 
the same in Java for a long time.

> the language has had.  That success a) led to a prolonged life and b) 
> steered more resources into the development of the language, libraries 
> and frameworks.  For another language people might not have bothered to 
> write another IO library.  Now there are is more than one around to 
> maintain compatibility and that makes the language look inconsistent - 
> even though it's just history showing.  Same story with Vector and 
> ArrayList or synchronized vs. java.util.concurrent.locks (where one is 
> really a language feature and the other a library) or Date vs. Calendar. 
> 
>   As Lew said, you need darn good library designers to get it right the 
> first time.  But at least you can see that newer parts of the library 
> are better than older parts.  I find that good even though it increases 
> the volume of library API to learn.

But learning about Exceptions isn't an API exercise, at this level, but 
a language-comprehension issue and whether one bothers to read the 
elementary introductions to the language.

Or then whines that the language is too hard because they didn't bother 
to learn the most elementary aspects of it in the first place.

-- 
Lew

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

can't throw bob smith <bob@coolfone.comze.com> - 2012-09-11 13:16 -0700
  Re: can't throw markspace <-@.> - 2012-09-11 13:34 -0700
    Re: can't throw Lew <lewbloch@gmail.com> - 2012-09-11 14:15 -0700
  Re: can't throw Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-09-11 17:02 -0400
    Re: can't throw Lew <lewbloch@gmail.com> - 2012-09-11 14:17 -0700
      Re: can't throw Arne Vajhøj <arne@vajhoej.dk> - 2012-09-11 21:21 -0400
        Re: can't throw Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2012-09-11 21:59 -0700
          Re: can't throw Gene Wirchenko <genew@ocis.net> - 2012-09-12 09:18 -0700
            Re: can't throw Robert Klemme <shortcutter@googlemail.com> - 2012-09-12 19:09 +0200
            Re: can't throw markspace <-@.> - 2012-09-12 10:56 -0700
            Re: can't throw Arne Vajhøj <arne@vajhoej.dk> - 2012-09-12 18:36 -0400
              Re: can't throw Gene Wirchenko <genew@ocis.net> - 2012-09-12 18:29 -0700
                Re: can't throw Patricia Shanahan <pats@acm.org> - 2012-09-12 18:34 -0700
                Re: can't throw Arne Vajhøj <arne@vajhoej.dk> - 2012-09-12 21:37 -0400
                Re: can't throw Arne Vajhøj <arne@vajhoej.dk> - 2012-09-12 21:54 -0400
          Re: can't throw Jim Janney <jjanney@shell.xmission.com> - 2012-09-12 11:27 -0600
          Re: can't throw Arne Vajhøj <arne@vajhoej.dk> - 2012-09-12 18:24 -0400
            Re: can't throw Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2012-09-13 22:20 -0700
              Re: can't throw Gene Wirchenko <genew@ocis.net> - 2012-09-14 09:49 -0700
                Re: can't throw Robert Klemme <shortcutter@googlemail.com> - 2012-09-14 20:50 +0200
                Re: can't throw Lew <lewbloch@gmail.com> - 2012-09-14 13:02 -0700
                Re: can't throw Gene Wirchenko <genew@ocis.net> - 2012-09-14 14:06 -0700
                Re: can't throw Gene Wirchenko <genew@ocis.net> - 2012-09-14 13:16 -0700
                Re: can't throw Robert Klemme <shortcutter@googlemail.com> - 2012-09-14 23:07 +0200
                Re: can't throw Lew <lewbloch@gmail.com> - 2012-09-14 14:28 -0700
                Re: can't throw Gene Wirchenko <genew@ocis.net> - 2012-09-16 20:04 -0700
        Re: can't throw Arne Vajhøj <arne@vajhoej.dk> - 2012-09-12 18:16 -0400
          Re: can't throw Lew <lewbloch@gmail.com> - 2012-09-12 23:15 -0700
        Re: can't throw Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-09-14 17:33 -0500
          Re: can't throw Robert Klemme <shortcutter@googlemail.com> - 2012-09-16 15:46 +0200
            Re: can't throw Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-09-16 12:17 -0500
              Re: can't throw Robert Klemme <shortcutter@googlemail.com> - 2012-09-16 22:36 +0200
                Re: can't throw Gene Wirchenko <genew@ocis.net> - 2012-09-16 20:07 -0700
                Re: can't throw Robert Klemme <shortcutter@googlemail.com> - 2012-09-17 07:41 +0200
                Re: can't throw Gene Wirchenko <genew@ocis.net> - 2012-09-17 09:51 -0700
                Re: can't throw Robert Klemme <shortcutter@googlemail.com> - 2012-09-17 21:00 +0200
                Re: can't throw Gene Wirchenko <genew@ocis.net> - 2012-09-17 13:23 -0700
                Re: can't throw Joerg Meier <joergmmeier@arcor.de> - 2012-09-17 18:52 +0200
                Re: can't throw Lew <lewbloch@gmail.com> - 2012-09-17 11:22 -0700
                Re: can't throw Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-09-17 02:52 -0500
                Re: can't throw Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-09-17 02:39 -0500
                Re: can't throw Robert Klemme <shortcutter@googlemail.com> - 2012-09-17 21:02 +0200
  Re: can't throw markspace <-@.> - 2012-09-11 14:28 -0700
  Re: can't throw Arne Vajhøj <arne@vajhoej.dk> - 2012-09-11 21:14 -0400
    Re: can't throw Arne Vajhøj <arne@vajhoej.dk> - 2012-09-12 18:11 -0400
  Re: can't throw Robert Klemme <shortcutter@googlemail.com> - 2012-09-12 08:31 +0200
    Re: can't throw bob smith <bob@coolfone.comze.com> - 2012-09-12 11:40 -0700
      Re: can't throw Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-09-12 15:50 -0400
      Re: can't throw Lew <lewbloch@gmail.com> - 2012-09-12 12:52 -0700
        Re: can't throw Robert Klemme <shortcutter@googlemail.com> - 2012-09-12 23:24 +0200
          Re: can't throw Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-09-12 15:10 -0700
            Re: can't throw Robert Klemme <shortcutter@googlemail.com> - 2012-09-13 23:32 +0200
    Re: can't throw Arne Vajhøj <arne@vajhoej.dk> - 2012-09-12 18:06 -0400
  Re: can't throw Roedy Green <see_website@mindprod.com.invalid> - 2012-09-12 20:55 -0700

csiph-web