Re: a criticism of java
- From: "ricky.clarkson@xxxxxxxxx" <ricky.clarkson@xxxxxxxxx>
- Date: 18 Dec 2005 13:35:19 -0800
> a)Integer.parseInt was one of the method that got up my nose. It
> throws a NumberFormatException - which is, checked.
The problem with the test-first strategy is that you are duplicating
effort. Nearly all the effort required to parse an int is required to
verify an int.
See the recent thread on "Using exceptions for early exit" in
comp.lang.java.programmer for my suggestions (and some
counter-arguments) on alternative ways of doing this.
> But since i'm writing a single
> user / single thread, application, that sort of mischief isn't
> expected
I would never trust a user (even/especially myself) not to delete a
file under my nose. If you can trust a user, then you are dealing with
a VERY VERY rare case. Most users do mischevious things if they can.
By the way, FileReader is worth avoiding because you can't set its
encoding. It uses the default platform encoding (unless you change
that). It's better to use InputStreamReader, I think.
> Regardign c - br.read(..) . that I can understand, if it's a big
> file, maybe the file will disappear.
I don't think a file can be deleted if you're reading from it, but that
might be OS-dependent. However, a filesystem might disappear,
especially a remote one.
Also, you might close the FileReader before the BufferedReader, so the
BufferedReader has to throw an IOException in that case.
The problem with using this construct:
try
{
code
}
catch (final Exception exception)
{
if (exception instanceof RuntimeException)
throw (RuntimeException(exception;
logger.log(exception);
}
is that it is not explicit. You might think that you're handling an
IOException and a NumberFormatException with it, then you might add
some code that does an SQL query. It will silently start catching
SQLException, and just logging it. It would be better to have to deal
with SQLException, so that you can, e.g., close the database Connection
and System.exit(1); or whatever you want to do in the case of an
SQLException.
Being explicit is good for avoiding bugs, but not good for stopping you
from having to type a lot. I don't mind typing a lot (if you haven't
noticed). I do mind hunting bugs.
.
- References:
- Re: a criticism of java
- From: q_q_anonymous
- Re: a criticism of java
- From: Oliver Wong
- Re: a criticism of java
- From: q_q_anonymous
- Re: a criticism of java
- From: Patrick May
- Re: a criticism of java
- From: q_q_anonymous
- Re: a criticism of java
- From: Dimitri Maziuk
- Re: a criticism of java
- From: q_q_anonymous
- Re: a criticism of java
- From: Hendrik Maryns
- Re: a criticism of java
- From: q_q_anonymous
- Re: a criticism of java
- From: Hendrik Maryns
- Re: a criticism of java
- From: q_q_anonymous
- Re: a criticism of java
- From: Hendrik Maryns
- Re: a criticism of java
- From: q_q_anonymous
- Re: a criticism of java
- From: ricky.clarkson@xxxxxxxxx
- Re: a criticism of java
- From: q_q_anonymous
- Re: a criticism of java
- From: q_q_anonymous
- Re: a criticism of java
- Prev by Date: what is JAD?
- Next by Date: [OT] Space remaining on ISP's free webspace
- Previous by thread: Re: a criticism of java
- Next by thread: Re: a criticism of java
- Index(es):
Relevant Pages
|