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 <[EMAIL PROTECTED]> 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 [EMAIL PROTECTED]
>


--
Jeremiah Rogers

---------------------------------------------------------------------
The Cryptography Mailing List
Unsubscribe by sending "unsubscribe cryptography" to [EMAIL PROTECTED]

Reply via email to