Java: Helping the world build bigger idiots

Jeremiah Rogers jeremiah at kingprimate.com
Mon Sep 19 12:17:44 EDT 2005


It used to be that checking bounds on certain collections was less
efficient than waiting for the out of bounds exception. I think Joshua
Bloch discusses this in his book.

I've also seen this in generated code where you aren't sure of the
nature of the object you're indexing and thus don't know the
appropriate length variable (.length vs .length()).

That said it's still awful.

On 9/19/05, Peter Gutmann <pgut001 at cs.auckland.ac.nz> wrote:
> Found on the Daily WTF, http://www.thedailywtf.com/forums/43223/ShowPost.aspx:
>
>  try {
>    int idx = 0;
>
>    while (true) {
>      displayProductInfo(prodnums[idx]);
>      idx++;
>      }
>    }
>  catch (IndexOutOfBoundException ex) {
>    // nil
>    }
>
> The editor also comments that when he got the first few of these submitted he
> rejected them as being faked, but ended up with so many that he realised this
> usage must be relatively common.
>
> Peter.
>
> ---------------------------------------------------------------------
> The Cryptography Mailing List
> Unsubscribe by sending "unsubscribe cryptography" to majordomo at metzdowd.com
>


--
Jeremiah Rogers

---------------------------------------------------------------------
The Cryptography Mailing List
Unsubscribe by sending "unsubscribe cryptography" to majordomo at metzdowd.com



More information about the cryptography mailing list