the array of hope

An old friend from TAMS sent me this url today. It links to a particularly … horrid example of programming practice. Our conversation follows.

(15:40:34) Matt: must… not… look…
(15:40:52) Ammon: huh?
(15:41:00) Matt: (look ;-))
(15:41:29) Ammon: …
(15:41:34) Ammon: _wow_
(15:42:00) Matt: hooray for exceptions
(15:42:05) Ammon: that’s just obscene
(15:43:13) Ammon: … it
(15:43:17) Ammon: it hurts my soul
(15:43:27) Matt: deep down, where the pie goes?
(15:43:28) Matt: yeah
(15:43:32) Ammon: yeah

The code in question (for those who don’t want to follow the link)?

I don’t know if I really want to explain what’s wrong with this for those non-programmers who might be reading… No. I don’t. But I will anyway.

Since time immemorial, the most common way to iterate over an list of values has been to use an index variable that is incremented until it reaches the size of the list. And then you stop. And you don’t continue to look at things. If you try to look beyond the end of the list, strange and unpredictable things can happen – exactly what happens depending on the system involved.

This program … does an infinite loop, increments its counter, and then crashes when it runs past the end of the list of product id’s to be displayed. But, it plans on crashing. So it knows to just ignore the disturbance in the Force that is generated and continue running despite the millions of souls crying in agony before being silenced by the idiot programmer who is being paid to murder them in their sleep.

Leave a Reply

Your email address will not be published. Required fields are marked *