Today's Code Snippet comes from two different people, Nate and Mike. I felt these were each too small to post by themselves(maybe we'll get to 200 comments?!), so I decided to give a little more. To try a little harder. To reach a little deeper. To, to... Never mind, here's the code.
Nate writes, "Having recently started a new programming job, I've quickly discovered what most of the day-to-day grind entails: Deciphering and cleaning poorly written Visual Basic code before actually being able to perform my assigned work. Our code base has plenty of the usual suspects: Variables with meaningless names like "AA" and "bbb", thousand-line functions (which approach VB's built-in limits), no-ops, unreachable code, gobs of copy-and-pasted code, and a few instances of this little construct (irrelevant code removed):"
If {condition} Then ' ...code here Goto skipIt End If ' ...more code here skipIt:
Apparently, someone isn't familiar with the concept of an "Else" block.
Our second snippet comes from Mike who writes, "I know an intern was working on this code, but I'm afraid that it might not have been them that did this..."
#if defined COMPILER_GCC printf("configuration: " CONFIG_STRING "\n"); #elif defined COMPILER_XYZ /* XYZ doesn't seem to support concatenation like that */ printf("configuration: "); printf( CONFIG_STRING ); printf( "\n"); #endif
Moral of the story? Pogo was right. We have met the enemy and he is us.