All Code Sucks


All code sucks1. Including my own. These pages hold a growing collection of code fragments that have caused people various amounts of
frustration and aggravation. All of them are real. Some are modified:
names of variables or functions may be changed, comments deleted,
logic simplified to better illustrate the point, and certainly names
withheld to protect the guilty. Some fragments may be stripped down
to or beyond the bare minimum because the details are irrelevant. 

All of it though is real. None will be accepted here unless the submitter swears on his or her firewall rules that the code really exists (or existed) in the wild. Of course the submitter's word will be taken at face value...

There is no danger in that, because no one is able to invent anything more weird than code we see all too often in the wild. 


1 Sometimes I am asked, "Do you really believe that all code sucks?" No, I don't. As a matter of fact I've seen some pretty good code in my life. Invariably though, the people who write good code know intuitively what Alan Perlis put so succinctly in one of his Epigrams of Programming:

"There are two ways to write error-free programs; only the third one works."