> Have you any examples of poor or even terrible code that has really left you scrambling for a resolution to a weird error?
How about this one.
Several thousand lines of code.
No comments.
The only variable declarations are to declare something private and that only explicitly declared when he wanted to use the same name for a different purpose.
The most descriptive variable name was calias which was used to store the alias of the table/cursor he wanted to work on in that procedure.
Now when your 10 levels down in the code and trying to work out what table is supposed to be worked on with 7 or 8 of the levels redclaring calias as private and the others just using the calias from the parent you start doing one of 2 things. Swearing or crying (sometimes both) especially when the line of code with a problem is something like
calias = bob
and bob wasn't declared anywhere but was set with bob = "somevalue" in the top level of code.
bob wasn't the actual variable name but it is about as descriptive (if not more so) as the variable that was used.
It took weeks of gradually stepping through and immediately adding comments the moment I knew what any particular line did, or even what any particular variable meant before I could start changing it to a more manageable form. A complete rewrite would have been my preference but it wasn't an option so I had to settle for giving variables and procedures proper descriptive names, commenting liberally, and making sure that variables are passed as parameters down the stack where needed.